http://git-wip-us.apache.org/repos/asf/hbase-site/blob/e312f773/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.TestBase.html ---------------------------------------------------------------------- diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.TestBase.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.TestBase.html index e38835a..e11b644 100644 --- a/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.TestBase.html +++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.TestBase.html @@ -2220,698 +2220,702 @@ <span class="sourceLineNo">2212</span><a name="line.2212"></a> <span class="sourceLineNo">2213</span> FilteredScanTest(Connection con, TestOptions options, Status status) {<a name="line.2213"></a> <span class="sourceLineNo">2214</span> super(con, options, status);<a name="line.2214"></a> -<span class="sourceLineNo">2215</span> }<a name="line.2215"></a> -<span class="sourceLineNo">2216</span><a name="line.2216"></a> -<span class="sourceLineNo">2217</span> @Override<a name="line.2217"></a> -<span class="sourceLineNo">2218</span> boolean testRow(int i) throws IOException {<a name="line.2218"></a> -<span class="sourceLineNo">2219</span> byte[] value = generateData(this.rand, getValueLength(this.rand));<a name="line.2219"></a> -<span class="sourceLineNo">2220</span> Scan scan = constructScan(value);<a name="line.2220"></a> -<span class="sourceLineNo">2221</span> ResultScanner scanner = null;<a name="line.2221"></a> -<span class="sourceLineNo">2222</span> try {<a name="line.2222"></a> -<span class="sourceLineNo">2223</span> scanner = this.table.getScanner(scan);<a name="line.2223"></a> -<span class="sourceLineNo">2224</span> for (Result r = null; (r = scanner.next()) != null;) {<a name="line.2224"></a> -<span class="sourceLineNo">2225</span> updateValueSize(r);<a name="line.2225"></a> -<span class="sourceLineNo">2226</span> }<a name="line.2226"></a> -<span class="sourceLineNo">2227</span> } finally {<a name="line.2227"></a> -<span class="sourceLineNo">2228</span> if (scanner != null) {<a name="line.2228"></a> -<span class="sourceLineNo">2229</span> updateScanMetrics(scanner.getScanMetrics());<a name="line.2229"></a> -<span class="sourceLineNo">2230</span> scanner.close();<a name="line.2230"></a> -<span class="sourceLineNo">2231</span> }<a name="line.2231"></a> -<span class="sourceLineNo">2232</span> }<a name="line.2232"></a> -<span class="sourceLineNo">2233</span> return true;<a name="line.2233"></a> -<span class="sourceLineNo">2234</span> }<a name="line.2234"></a> -<span class="sourceLineNo">2235</span><a name="line.2235"></a> -<span class="sourceLineNo">2236</span> protected Scan constructScan(byte[] valuePrefix) throws IOException {<a name="line.2236"></a> -<span class="sourceLineNo">2237</span> FilterList list = new FilterList();<a name="line.2237"></a> -<span class="sourceLineNo">2238</span> Filter filter = new SingleColumnValueFilter(FAMILY_ZERO, COLUMN_ZERO,<a name="line.2238"></a> -<span class="sourceLineNo">2239</span> CompareOperator.EQUAL, new BinaryComparator(valuePrefix));<a name="line.2239"></a> -<span class="sourceLineNo">2240</span> list.addFilter(filter);<a name="line.2240"></a> -<span class="sourceLineNo">2241</span> if (opts.filterAll) {<a name="line.2241"></a> -<span class="sourceLineNo">2242</span> list.addFilter(new FilterAllFilter());<a name="line.2242"></a> -<span class="sourceLineNo">2243</span> }<a name="line.2243"></a> -<span class="sourceLineNo">2244</span> Scan scan = new Scan().setCaching(opts.caching).setCacheBlocks(opts.cacheBlocks)<a name="line.2244"></a> -<span class="sourceLineNo">2245</span> .setAsyncPrefetch(opts.asyncPrefetch).setReadType(opts.scanReadType)<a name="line.2245"></a> -<span class="sourceLineNo">2246</span> .setScanMetricsEnabled(true);<a name="line.2246"></a> -<span class="sourceLineNo">2247</span> if (opts.addColumns) {<a name="line.2247"></a> -<span class="sourceLineNo">2248</span> for (int column = 0; column < opts.columns; column++) {<a name="line.2248"></a> -<span class="sourceLineNo">2249</span> byte [] qualifier = column == 0? COLUMN_ZERO: Bytes.toBytes("" + column);<a name="line.2249"></a> -<span class="sourceLineNo">2250</span> scan.addColumn(FAMILY_ZERO, qualifier);<a name="line.2250"></a> -<span class="sourceLineNo">2251</span> }<a name="line.2251"></a> -<span class="sourceLineNo">2252</span> } else {<a name="line.2252"></a> -<span class="sourceLineNo">2253</span> scan.addFamily(FAMILY_ZERO);<a name="line.2253"></a> -<span class="sourceLineNo">2254</span> }<a name="line.2254"></a> -<span class="sourceLineNo">2255</span> scan.setFilter(list);<a name="line.2255"></a> -<span class="sourceLineNo">2256</span> return scan;<a name="line.2256"></a> -<span class="sourceLineNo">2257</span> }<a name="line.2257"></a> -<span class="sourceLineNo">2258</span> }<a name="line.2258"></a> -<span class="sourceLineNo">2259</span><a name="line.2259"></a> -<span class="sourceLineNo">2260</span> /**<a name="line.2260"></a> -<span class="sourceLineNo">2261</span> * Compute a throughput rate in MB/s.<a name="line.2261"></a> -<span class="sourceLineNo">2262</span> * @param rows Number of records consumed.<a name="line.2262"></a> -<span class="sourceLineNo">2263</span> * @param timeMs Time taken in milliseconds.<a name="line.2263"></a> -<span class="sourceLineNo">2264</span> * @return String value with label, ie '123.76 MB/s'<a name="line.2264"></a> -<span class="sourceLineNo">2265</span> */<a name="line.2265"></a> -<span class="sourceLineNo">2266</span> private static String calculateMbps(int rows, long timeMs, final int valueSize, int families, int columns) {<a name="line.2266"></a> -<span class="sourceLineNo">2267</span> BigDecimal rowSize = BigDecimal.valueOf(ROW_LENGTH +<a name="line.2267"></a> -<span class="sourceLineNo">2268</span> ((valueSize + (FAMILY_NAME_BASE.length()+1) + COLUMN_ZERO.length) * columns) * families);<a name="line.2268"></a> -<span class="sourceLineNo">2269</span> BigDecimal mbps = BigDecimal.valueOf(rows).multiply(rowSize, CXT)<a name="line.2269"></a> -<span class="sourceLineNo">2270</span> .divide(BigDecimal.valueOf(timeMs), CXT).multiply(MS_PER_SEC, CXT)<a name="line.2270"></a> -<span class="sourceLineNo">2271</span> .divide(BYTES_PER_MB, CXT);<a name="line.2271"></a> -<span class="sourceLineNo">2272</span> return FMT.format(mbps) + " MB/s";<a name="line.2272"></a> -<span class="sourceLineNo">2273</span> }<a name="line.2273"></a> -<span class="sourceLineNo">2274</span><a name="line.2274"></a> -<span class="sourceLineNo">2275</span> /*<a name="line.2275"></a> -<span class="sourceLineNo">2276</span> * Format passed integer.<a name="line.2276"></a> -<span class="sourceLineNo">2277</span> * @param number<a name="line.2277"></a> -<span class="sourceLineNo">2278</span> * @return Returns zero-prefixed ROW_LENGTH-byte wide decimal version of passed<a name="line.2278"></a> -<span class="sourceLineNo">2279</span> * number (Does absolute in case number is negative).<a name="line.2279"></a> -<span class="sourceLineNo">2280</span> */<a name="line.2280"></a> -<span class="sourceLineNo">2281</span> public static byte [] format(final int number) {<a name="line.2281"></a> -<span class="sourceLineNo">2282</span> byte [] b = new byte[ROW_LENGTH];<a name="line.2282"></a> -<span class="sourceLineNo">2283</span> int d = Math.abs(number);<a name="line.2283"></a> -<span class="sourceLineNo">2284</span> for (int i = b.length - 1; i >= 0; i--) {<a name="line.2284"></a> -<span class="sourceLineNo">2285</span> b[i] = (byte)((d % 10) + '0');<a name="line.2285"></a> -<span class="sourceLineNo">2286</span> d /= 10;<a name="line.2286"></a> -<span class="sourceLineNo">2287</span> }<a name="line.2287"></a> -<span class="sourceLineNo">2288</span> return b;<a name="line.2288"></a> -<span class="sourceLineNo">2289</span> }<a name="line.2289"></a> -<span class="sourceLineNo">2290</span><a name="line.2290"></a> -<span class="sourceLineNo">2291</span> /*<a name="line.2291"></a> -<span class="sourceLineNo">2292</span> * This method takes some time and is done inline uploading data. For<a name="line.2292"></a> -<span class="sourceLineNo">2293</span> * example, doing the mapfile test, generation of the key and value<a name="line.2293"></a> -<span class="sourceLineNo">2294</span> * consumes about 30% of CPU time.<a name="line.2294"></a> -<span class="sourceLineNo">2295</span> * @return Generated random value to insert into a table cell.<a name="line.2295"></a> -<span class="sourceLineNo">2296</span> */<a name="line.2296"></a> -<span class="sourceLineNo">2297</span> public static byte[] generateData(final Random r, int length) {<a name="line.2297"></a> -<span class="sourceLineNo">2298</span> byte [] b = new byte [length];<a name="line.2298"></a> -<span class="sourceLineNo">2299</span> int i;<a name="line.2299"></a> -<span class="sourceLineNo">2300</span><a name="line.2300"></a> -<span class="sourceLineNo">2301</span> for(i = 0; i < (length-8); i += 8) {<a name="line.2301"></a> -<span class="sourceLineNo">2302</span> b[i] = (byte) (65 + r.nextInt(26));<a name="line.2302"></a> -<span class="sourceLineNo">2303</span> b[i+1] = b[i];<a name="line.2303"></a> -<span class="sourceLineNo">2304</span> b[i+2] = b[i];<a name="line.2304"></a> -<span class="sourceLineNo">2305</span> b[i+3] = b[i];<a name="line.2305"></a> -<span class="sourceLineNo">2306</span> b[i+4] = b[i];<a name="line.2306"></a> -<span class="sourceLineNo">2307</span> b[i+5] = b[i];<a name="line.2307"></a> -<span class="sourceLineNo">2308</span> b[i+6] = b[i];<a name="line.2308"></a> -<span class="sourceLineNo">2309</span> b[i+7] = b[i];<a name="line.2309"></a> -<span class="sourceLineNo">2310</span> }<a name="line.2310"></a> -<span class="sourceLineNo">2311</span><a name="line.2311"></a> -<span class="sourceLineNo">2312</span> byte a = (byte) (65 + r.nextInt(26));<a name="line.2312"></a> -<span class="sourceLineNo">2313</span> for(; i < length; i++) {<a name="line.2313"></a> -<span class="sourceLineNo">2314</span> b[i] = a;<a name="line.2314"></a> -<span class="sourceLineNo">2315</span> }<a name="line.2315"></a> -<span class="sourceLineNo">2316</span> return b;<a name="line.2316"></a> -<span class="sourceLineNo">2317</span> }<a name="line.2317"></a> -<span class="sourceLineNo">2318</span><a name="line.2318"></a> -<span class="sourceLineNo">2319</span> static byte [] getRandomRow(final Random random, final int totalRows) {<a name="line.2319"></a> -<span class="sourceLineNo">2320</span> return format(generateRandomRow(random, totalRows));<a name="line.2320"></a> +<span class="sourceLineNo">2215</span> if (opts.perClientRunRows == DEFAULT_ROWS_PER_GB) {<a name="line.2215"></a> +<span class="sourceLineNo">2216</span> LOG.warn("Option \"rows\" unspecified. Using default value " + DEFAULT_ROWS_PER_GB +<a name="line.2216"></a> +<span class="sourceLineNo">2217</span> ". This could take a very long time.");<a name="line.2217"></a> +<span class="sourceLineNo">2218</span> }<a name="line.2218"></a> +<span class="sourceLineNo">2219</span> }<a name="line.2219"></a> +<span class="sourceLineNo">2220</span><a name="line.2220"></a> +<span class="sourceLineNo">2221</span> @Override<a name="line.2221"></a> +<span class="sourceLineNo">2222</span> boolean testRow(int i) throws IOException {<a name="line.2222"></a> +<span class="sourceLineNo">2223</span> byte[] value = generateData(this.rand, getValueLength(this.rand));<a name="line.2223"></a> +<span class="sourceLineNo">2224</span> Scan scan = constructScan(value);<a name="line.2224"></a> +<span class="sourceLineNo">2225</span> ResultScanner scanner = null;<a name="line.2225"></a> +<span class="sourceLineNo">2226</span> try {<a name="line.2226"></a> +<span class="sourceLineNo">2227</span> scanner = this.table.getScanner(scan);<a name="line.2227"></a> +<span class="sourceLineNo">2228</span> for (Result r = null; (r = scanner.next()) != null;) {<a name="line.2228"></a> +<span class="sourceLineNo">2229</span> updateValueSize(r);<a name="line.2229"></a> +<span class="sourceLineNo">2230</span> }<a name="line.2230"></a> +<span class="sourceLineNo">2231</span> } finally {<a name="line.2231"></a> +<span class="sourceLineNo">2232</span> if (scanner != null) {<a name="line.2232"></a> +<span class="sourceLineNo">2233</span> updateScanMetrics(scanner.getScanMetrics());<a name="line.2233"></a> +<span class="sourceLineNo">2234</span> scanner.close();<a name="line.2234"></a> +<span class="sourceLineNo">2235</span> }<a name="line.2235"></a> +<span class="sourceLineNo">2236</span> }<a name="line.2236"></a> +<span class="sourceLineNo">2237</span> return true;<a name="line.2237"></a> +<span class="sourceLineNo">2238</span> }<a name="line.2238"></a> +<span class="sourceLineNo">2239</span><a name="line.2239"></a> +<span class="sourceLineNo">2240</span> protected Scan constructScan(byte[] valuePrefix) throws IOException {<a name="line.2240"></a> +<span class="sourceLineNo">2241</span> FilterList list = new FilterList();<a name="line.2241"></a> +<span class="sourceLineNo">2242</span> Filter filter = new SingleColumnValueFilter(FAMILY_ZERO, COLUMN_ZERO,<a name="line.2242"></a> +<span class="sourceLineNo">2243</span> CompareOperator.EQUAL, new BinaryComparator(valuePrefix));<a name="line.2243"></a> +<span class="sourceLineNo">2244</span> list.addFilter(filter);<a name="line.2244"></a> +<span class="sourceLineNo">2245</span> if (opts.filterAll) {<a name="line.2245"></a> +<span class="sourceLineNo">2246</span> list.addFilter(new FilterAllFilter());<a name="line.2246"></a> +<span class="sourceLineNo">2247</span> }<a name="line.2247"></a> +<span class="sourceLineNo">2248</span> Scan scan = new Scan().setCaching(opts.caching).setCacheBlocks(opts.cacheBlocks)<a name="line.2248"></a> +<span class="sourceLineNo">2249</span> .setAsyncPrefetch(opts.asyncPrefetch).setReadType(opts.scanReadType)<a name="line.2249"></a> +<span class="sourceLineNo">2250</span> .setScanMetricsEnabled(true);<a name="line.2250"></a> +<span class="sourceLineNo">2251</span> if (opts.addColumns) {<a name="line.2251"></a> +<span class="sourceLineNo">2252</span> for (int column = 0; column < opts.columns; column++) {<a name="line.2252"></a> +<span class="sourceLineNo">2253</span> byte [] qualifier = column == 0? COLUMN_ZERO: Bytes.toBytes("" + column);<a name="line.2253"></a> +<span class="sourceLineNo">2254</span> scan.addColumn(FAMILY_ZERO, qualifier);<a name="line.2254"></a> +<span class="sourceLineNo">2255</span> }<a name="line.2255"></a> +<span class="sourceLineNo">2256</span> } else {<a name="line.2256"></a> +<span class="sourceLineNo">2257</span> scan.addFamily(FAMILY_ZERO);<a name="line.2257"></a> +<span class="sourceLineNo">2258</span> }<a name="line.2258"></a> +<span class="sourceLineNo">2259</span> scan.setFilter(list);<a name="line.2259"></a> +<span class="sourceLineNo">2260</span> return scan;<a name="line.2260"></a> +<span class="sourceLineNo">2261</span> }<a name="line.2261"></a> +<span class="sourceLineNo">2262</span> }<a name="line.2262"></a> +<span class="sourceLineNo">2263</span><a name="line.2263"></a> +<span class="sourceLineNo">2264</span> /**<a name="line.2264"></a> +<span class="sourceLineNo">2265</span> * Compute a throughput rate in MB/s.<a name="line.2265"></a> +<span class="sourceLineNo">2266</span> * @param rows Number of records consumed.<a name="line.2266"></a> +<span class="sourceLineNo">2267</span> * @param timeMs Time taken in milliseconds.<a name="line.2267"></a> +<span class="sourceLineNo">2268</span> * @return String value with label, ie '123.76 MB/s'<a name="line.2268"></a> +<span class="sourceLineNo">2269</span> */<a name="line.2269"></a> +<span class="sourceLineNo">2270</span> private static String calculateMbps(int rows, long timeMs, final int valueSize, int families, int columns) {<a name="line.2270"></a> +<span class="sourceLineNo">2271</span> BigDecimal rowSize = BigDecimal.valueOf(ROW_LENGTH +<a name="line.2271"></a> +<span class="sourceLineNo">2272</span> ((valueSize + (FAMILY_NAME_BASE.length()+1) + COLUMN_ZERO.length) * columns) * families);<a name="line.2272"></a> +<span class="sourceLineNo">2273</span> BigDecimal mbps = BigDecimal.valueOf(rows).multiply(rowSize, CXT)<a name="line.2273"></a> +<span class="sourceLineNo">2274</span> .divide(BigDecimal.valueOf(timeMs), CXT).multiply(MS_PER_SEC, CXT)<a name="line.2274"></a> +<span class="sourceLineNo">2275</span> .divide(BYTES_PER_MB, CXT);<a name="line.2275"></a> +<span class="sourceLineNo">2276</span> return FMT.format(mbps) + " MB/s";<a name="line.2276"></a> +<span class="sourceLineNo">2277</span> }<a name="line.2277"></a> +<span class="sourceLineNo">2278</span><a name="line.2278"></a> +<span class="sourceLineNo">2279</span> /*<a name="line.2279"></a> +<span class="sourceLineNo">2280</span> * Format passed integer.<a name="line.2280"></a> +<span class="sourceLineNo">2281</span> * @param number<a name="line.2281"></a> +<span class="sourceLineNo">2282</span> * @return Returns zero-prefixed ROW_LENGTH-byte wide decimal version of passed<a name="line.2282"></a> +<span class="sourceLineNo">2283</span> * number (Does absolute in case number is negative).<a name="line.2283"></a> +<span class="sourceLineNo">2284</span> */<a name="line.2284"></a> +<span class="sourceLineNo">2285</span> public static byte [] format(final int number) {<a name="line.2285"></a> +<span class="sourceLineNo">2286</span> byte [] b = new byte[ROW_LENGTH];<a name="line.2286"></a> +<span class="sourceLineNo">2287</span> int d = Math.abs(number);<a name="line.2287"></a> +<span class="sourceLineNo">2288</span> for (int i = b.length - 1; i >= 0; i--) {<a name="line.2288"></a> +<span class="sourceLineNo">2289</span> b[i] = (byte)((d % 10) + '0');<a name="line.2289"></a> +<span class="sourceLineNo">2290</span> d /= 10;<a name="line.2290"></a> +<span class="sourceLineNo">2291</span> }<a name="line.2291"></a> +<span class="sourceLineNo">2292</span> return b;<a name="line.2292"></a> +<span class="sourceLineNo">2293</span> }<a name="line.2293"></a> +<span class="sourceLineNo">2294</span><a name="line.2294"></a> +<span class="sourceLineNo">2295</span> /*<a name="line.2295"></a> +<span class="sourceLineNo">2296</span> * This method takes some time and is done inline uploading data. For<a name="line.2296"></a> +<span class="sourceLineNo">2297</span> * example, doing the mapfile test, generation of the key and value<a name="line.2297"></a> +<span class="sourceLineNo">2298</span> * consumes about 30% of CPU time.<a name="line.2298"></a> +<span class="sourceLineNo">2299</span> * @return Generated random value to insert into a table cell.<a name="line.2299"></a> +<span class="sourceLineNo">2300</span> */<a name="line.2300"></a> +<span class="sourceLineNo">2301</span> public static byte[] generateData(final Random r, int length) {<a name="line.2301"></a> +<span class="sourceLineNo">2302</span> byte [] b = new byte [length];<a name="line.2302"></a> +<span class="sourceLineNo">2303</span> int i;<a name="line.2303"></a> +<span class="sourceLineNo">2304</span><a name="line.2304"></a> +<span class="sourceLineNo">2305</span> for(i = 0; i < (length-8); i += 8) {<a name="line.2305"></a> +<span class="sourceLineNo">2306</span> b[i] = (byte) (65 + r.nextInt(26));<a name="line.2306"></a> +<span class="sourceLineNo">2307</span> b[i+1] = b[i];<a name="line.2307"></a> +<span class="sourceLineNo">2308</span> b[i+2] = b[i];<a name="line.2308"></a> +<span class="sourceLineNo">2309</span> b[i+3] = b[i];<a name="line.2309"></a> +<span class="sourceLineNo">2310</span> b[i+4] = b[i];<a name="line.2310"></a> +<span class="sourceLineNo">2311</span> b[i+5] = b[i];<a name="line.2311"></a> +<span class="sourceLineNo">2312</span> b[i+6] = b[i];<a name="line.2312"></a> +<span class="sourceLineNo">2313</span> b[i+7] = b[i];<a name="line.2313"></a> +<span class="sourceLineNo">2314</span> }<a name="line.2314"></a> +<span class="sourceLineNo">2315</span><a name="line.2315"></a> +<span class="sourceLineNo">2316</span> byte a = (byte) (65 + r.nextInt(26));<a name="line.2316"></a> +<span class="sourceLineNo">2317</span> for(; i < length; i++) {<a name="line.2317"></a> +<span class="sourceLineNo">2318</span> b[i] = a;<a name="line.2318"></a> +<span class="sourceLineNo">2319</span> }<a name="line.2319"></a> +<span class="sourceLineNo">2320</span> return b;<a name="line.2320"></a> <span class="sourceLineNo">2321</span> }<a name="line.2321"></a> <span class="sourceLineNo">2322</span><a name="line.2322"></a> -<span class="sourceLineNo">2323</span> static int generateRandomRow(final Random random, final int totalRows) {<a name="line.2323"></a> -<span class="sourceLineNo">2324</span> return random.nextInt(Integer.MAX_VALUE) % totalRows;<a name="line.2324"></a> +<span class="sourceLineNo">2323</span> static byte [] getRandomRow(final Random random, final int totalRows) {<a name="line.2323"></a> +<span class="sourceLineNo">2324</span> return format(generateRandomRow(random, totalRows));<a name="line.2324"></a> <span class="sourceLineNo">2325</span> }<a name="line.2325"></a> <span class="sourceLineNo">2326</span><a name="line.2326"></a> -<span class="sourceLineNo">2327</span> static RunResult runOneClient(final Class<? extends TestBase> cmd, Configuration conf,<a name="line.2327"></a> -<span class="sourceLineNo">2328</span> Connection con, AsyncConnection asyncCon, TestOptions opts, final Status status)<a name="line.2328"></a> -<span class="sourceLineNo">2329</span> throws IOException, InterruptedException {<a name="line.2329"></a> -<span class="sourceLineNo">2330</span> status.setStatus("Start " + cmd + " at offset " + opts.startRow + " for "<a name="line.2330"></a> -<span class="sourceLineNo">2331</span> + opts.perClientRunRows + " rows");<a name="line.2331"></a> -<span class="sourceLineNo">2332</span> long totalElapsedTime;<a name="line.2332"></a> -<span class="sourceLineNo">2333</span><a name="line.2333"></a> -<span class="sourceLineNo">2334</span> final TestBase t;<a name="line.2334"></a> -<span class="sourceLineNo">2335</span> try {<a name="line.2335"></a> -<span class="sourceLineNo">2336</span> if (AsyncTest.class.isAssignableFrom(cmd)) {<a name="line.2336"></a> -<span class="sourceLineNo">2337</span> Class<? extends AsyncTest> newCmd = (Class<? extends AsyncTest>) cmd;<a name="line.2337"></a> -<span class="sourceLineNo">2338</span> Constructor<? extends AsyncTest> constructor =<a name="line.2338"></a> -<span class="sourceLineNo">2339</span> newCmd.getDeclaredConstructor(AsyncConnection.class, TestOptions.class, Status.class);<a name="line.2339"></a> -<span class="sourceLineNo">2340</span> t = constructor.newInstance(asyncCon, opts, status);<a name="line.2340"></a> -<span class="sourceLineNo">2341</span> } else {<a name="line.2341"></a> -<span class="sourceLineNo">2342</span> Class<? extends Test> newCmd = (Class<? extends Test>) cmd;<a name="line.2342"></a> -<span class="sourceLineNo">2343</span> Constructor<? extends Test> constructor =<a name="line.2343"></a> -<span class="sourceLineNo">2344</span> newCmd.getDeclaredConstructor(Connection.class, TestOptions.class, Status.class);<a name="line.2344"></a> -<span class="sourceLineNo">2345</span> t = constructor.newInstance(con, opts, status);<a name="line.2345"></a> -<span class="sourceLineNo">2346</span> }<a name="line.2346"></a> -<span class="sourceLineNo">2347</span> } catch (NoSuchMethodException e) {<a name="line.2347"></a> -<span class="sourceLineNo">2348</span> throw new IllegalArgumentException("Invalid command class: " + cmd.getName()<a name="line.2348"></a> -<span class="sourceLineNo">2349</span> + ". It does not provide a constructor as described by "<a name="line.2349"></a> -<span class="sourceLineNo">2350</span> + "the javadoc comment. Available constructors are: "<a name="line.2350"></a> -<span class="sourceLineNo">2351</span> + Arrays.toString(cmd.getConstructors()));<a name="line.2351"></a> -<span class="sourceLineNo">2352</span> } catch (Exception e) {<a name="line.2352"></a> -<span class="sourceLineNo">2353</span> throw new IllegalStateException("Failed to construct command class", e);<a name="line.2353"></a> -<span class="sourceLineNo">2354</span> }<a name="line.2354"></a> -<span class="sourceLineNo">2355</span> totalElapsedTime = t.test();<a name="line.2355"></a> -<span class="sourceLineNo">2356</span><a name="line.2356"></a> -<span class="sourceLineNo">2357</span> status.setStatus("Finished " + cmd + " in " + totalElapsedTime +<a name="line.2357"></a> -<span class="sourceLineNo">2358</span> "ms at offset " + opts.startRow + " for " + opts.perClientRunRows + " rows" +<a name="line.2358"></a> -<span class="sourceLineNo">2359</span> " (" + calculateMbps((int)(opts.perClientRunRows * opts.sampleRate), totalElapsedTime,<a name="line.2359"></a> -<span class="sourceLineNo">2360</span> getAverageValueLength(opts), opts.families, opts.columns) + ")");<a name="line.2360"></a> -<span class="sourceLineNo">2361</span><a name="line.2361"></a> -<span class="sourceLineNo">2362</span> return new RunResult(totalElapsedTime, t.getLatencyHistogram());<a name="line.2362"></a> -<span class="sourceLineNo">2363</span> }<a name="line.2363"></a> -<span class="sourceLineNo">2364</span><a name="line.2364"></a> -<span class="sourceLineNo">2365</span> private static int getAverageValueLength(final TestOptions opts) {<a name="line.2365"></a> -<span class="sourceLineNo">2366</span> return opts.valueRandom? opts.valueSize/2: opts.valueSize;<a name="line.2366"></a> +<span class="sourceLineNo">2327</span> static int generateRandomRow(final Random random, final int totalRows) {<a name="line.2327"></a> +<span class="sourceLineNo">2328</span> return random.nextInt(Integer.MAX_VALUE) % totalRows;<a name="line.2328"></a> +<span class="sourceLineNo">2329</span> }<a name="line.2329"></a> +<span class="sourceLineNo">2330</span><a name="line.2330"></a> +<span class="sourceLineNo">2331</span> static RunResult runOneClient(final Class<? extends TestBase> cmd, Configuration conf,<a name="line.2331"></a> +<span class="sourceLineNo">2332</span> Connection con, AsyncConnection asyncCon, TestOptions opts, final Status status)<a name="line.2332"></a> +<span class="sourceLineNo">2333</span> throws IOException, InterruptedException {<a name="line.2333"></a> +<span class="sourceLineNo">2334</span> status.setStatus("Start " + cmd + " at offset " + opts.startRow + " for "<a name="line.2334"></a> +<span class="sourceLineNo">2335</span> + opts.perClientRunRows + " rows");<a name="line.2335"></a> +<span class="sourceLineNo">2336</span> long totalElapsedTime;<a name="line.2336"></a> +<span class="sourceLineNo">2337</span><a name="line.2337"></a> +<span class="sourceLineNo">2338</span> final TestBase t;<a name="line.2338"></a> +<span class="sourceLineNo">2339</span> try {<a name="line.2339"></a> +<span class="sourceLineNo">2340</span> if (AsyncTest.class.isAssignableFrom(cmd)) {<a name="line.2340"></a> +<span class="sourceLineNo">2341</span> Class<? extends AsyncTest> newCmd = (Class<? extends AsyncTest>) cmd;<a name="line.2341"></a> +<span class="sourceLineNo">2342</span> Constructor<? extends AsyncTest> constructor =<a name="line.2342"></a> +<span class="sourceLineNo">2343</span> newCmd.getDeclaredConstructor(AsyncConnection.class, TestOptions.class, Status.class);<a name="line.2343"></a> +<span class="sourceLineNo">2344</span> t = constructor.newInstance(asyncCon, opts, status);<a name="line.2344"></a> +<span class="sourceLineNo">2345</span> } else {<a name="line.2345"></a> +<span class="sourceLineNo">2346</span> Class<? extends Test> newCmd = (Class<? extends Test>) cmd;<a name="line.2346"></a> +<span class="sourceLineNo">2347</span> Constructor<? extends Test> constructor =<a name="line.2347"></a> +<span class="sourceLineNo">2348</span> newCmd.getDeclaredConstructor(Connection.class, TestOptions.class, Status.class);<a name="line.2348"></a> +<span class="sourceLineNo">2349</span> t = constructor.newInstance(con, opts, status);<a name="line.2349"></a> +<span class="sourceLineNo">2350</span> }<a name="line.2350"></a> +<span class="sourceLineNo">2351</span> } catch (NoSuchMethodException e) {<a name="line.2351"></a> +<span class="sourceLineNo">2352</span> throw new IllegalArgumentException("Invalid command class: " + cmd.getName()<a name="line.2352"></a> +<span class="sourceLineNo">2353</span> + ". It does not provide a constructor as described by "<a name="line.2353"></a> +<span class="sourceLineNo">2354</span> + "the javadoc comment. Available constructors are: "<a name="line.2354"></a> +<span class="sourceLineNo">2355</span> + Arrays.toString(cmd.getConstructors()));<a name="line.2355"></a> +<span class="sourceLineNo">2356</span> } catch (Exception e) {<a name="line.2356"></a> +<span class="sourceLineNo">2357</span> throw new IllegalStateException("Failed to construct command class", e);<a name="line.2357"></a> +<span class="sourceLineNo">2358</span> }<a name="line.2358"></a> +<span class="sourceLineNo">2359</span> totalElapsedTime = t.test();<a name="line.2359"></a> +<span class="sourceLineNo">2360</span><a name="line.2360"></a> +<span class="sourceLineNo">2361</span> status.setStatus("Finished " + cmd + " in " + totalElapsedTime +<a name="line.2361"></a> +<span class="sourceLineNo">2362</span> "ms at offset " + opts.startRow + " for " + opts.perClientRunRows + " rows" +<a name="line.2362"></a> +<span class="sourceLineNo">2363</span> " (" + calculateMbps((int)(opts.perClientRunRows * opts.sampleRate), totalElapsedTime,<a name="line.2363"></a> +<span class="sourceLineNo">2364</span> getAverageValueLength(opts), opts.families, opts.columns) + ")");<a name="line.2364"></a> +<span class="sourceLineNo">2365</span><a name="line.2365"></a> +<span class="sourceLineNo">2366</span> return new RunResult(totalElapsedTime, t.getLatencyHistogram());<a name="line.2366"></a> <span class="sourceLineNo">2367</span> }<a name="line.2367"></a> <span class="sourceLineNo">2368</span><a name="line.2368"></a> -<span class="sourceLineNo">2369</span> private void runTest(final Class<? extends TestBase> cmd, TestOptions opts) throws IOException,<a name="line.2369"></a> -<span class="sourceLineNo">2370</span> InterruptedException, ClassNotFoundException, ExecutionException {<a name="line.2370"></a> -<span class="sourceLineNo">2371</span> // Log the configuration we're going to run with. Uses JSON mapper because lazy. It'll do<a name="line.2371"></a> -<span class="sourceLineNo">2372</span> // the TestOptions introspection for us and dump the output in a readable format.<a name="line.2372"></a> -<span class="sourceLineNo">2373</span> LOG.info(cmd.getSimpleName() + " test run options=" + MAPPER.writeValueAsString(opts));<a name="line.2373"></a> -<span class="sourceLineNo">2374</span> Admin admin = null;<a name="line.2374"></a> -<span class="sourceLineNo">2375</span> Connection connection = null;<a name="line.2375"></a> -<span class="sourceLineNo">2376</span> try {<a name="line.2376"></a> -<span class="sourceLineNo">2377</span> connection = ConnectionFactory.createConnection(getConf());<a name="line.2377"></a> -<span class="sourceLineNo">2378</span> admin = connection.getAdmin();<a name="line.2378"></a> -<span class="sourceLineNo">2379</span> checkTable(admin, opts);<a name="line.2379"></a> -<span class="sourceLineNo">2380</span> } finally {<a name="line.2380"></a> -<span class="sourceLineNo">2381</span> if (admin != null) admin.close();<a name="line.2381"></a> -<span class="sourceLineNo">2382</span> if (connection != null) connection.close();<a name="line.2382"></a> -<span class="sourceLineNo">2383</span> }<a name="line.2383"></a> -<span class="sourceLineNo">2384</span> if (opts.nomapred) {<a name="line.2384"></a> -<span class="sourceLineNo">2385</span> doLocalClients(opts, getConf());<a name="line.2385"></a> -<span class="sourceLineNo">2386</span> } else {<a name="line.2386"></a> -<span class="sourceLineNo">2387</span> doMapReduce(opts, getConf());<a name="line.2387"></a> -<span class="sourceLineNo">2388</span> }<a name="line.2388"></a> -<span class="sourceLineNo">2389</span> }<a name="line.2389"></a> -<span class="sourceLineNo">2390</span><a name="line.2390"></a> -<span class="sourceLineNo">2391</span> protected void printUsage() {<a name="line.2391"></a> -<span class="sourceLineNo">2392</span> printUsage(PE_COMMAND_SHORTNAME, null);<a name="line.2392"></a> +<span class="sourceLineNo">2369</span> private static int getAverageValueLength(final TestOptions opts) {<a name="line.2369"></a> +<span class="sourceLineNo">2370</span> return opts.valueRandom? opts.valueSize/2: opts.valueSize;<a name="line.2370"></a> +<span class="sourceLineNo">2371</span> }<a name="line.2371"></a> +<span class="sourceLineNo">2372</span><a name="line.2372"></a> +<span class="sourceLineNo">2373</span> private void runTest(final Class<? extends TestBase> cmd, TestOptions opts) throws IOException,<a name="line.2373"></a> +<span class="sourceLineNo">2374</span> InterruptedException, ClassNotFoundException, ExecutionException {<a name="line.2374"></a> +<span class="sourceLineNo">2375</span> // Log the configuration we're going to run with. Uses JSON mapper because lazy. It'll do<a name="line.2375"></a> +<span class="sourceLineNo">2376</span> // the TestOptions introspection for us and dump the output in a readable format.<a name="line.2376"></a> +<span class="sourceLineNo">2377</span> LOG.info(cmd.getSimpleName() + " test run options=" + MAPPER.writeValueAsString(opts));<a name="line.2377"></a> +<span class="sourceLineNo">2378</span> Admin admin = null;<a name="line.2378"></a> +<span class="sourceLineNo">2379</span> Connection connection = null;<a name="line.2379"></a> +<span class="sourceLineNo">2380</span> try {<a name="line.2380"></a> +<span class="sourceLineNo">2381</span> connection = ConnectionFactory.createConnection(getConf());<a name="line.2381"></a> +<span class="sourceLineNo">2382</span> admin = connection.getAdmin();<a name="line.2382"></a> +<span class="sourceLineNo">2383</span> checkTable(admin, opts);<a name="line.2383"></a> +<span class="sourceLineNo">2384</span> } finally {<a name="line.2384"></a> +<span class="sourceLineNo">2385</span> if (admin != null) admin.close();<a name="line.2385"></a> +<span class="sourceLineNo">2386</span> if (connection != null) connection.close();<a name="line.2386"></a> +<span class="sourceLineNo">2387</span> }<a name="line.2387"></a> +<span class="sourceLineNo">2388</span> if (opts.nomapred) {<a name="line.2388"></a> +<span class="sourceLineNo">2389</span> doLocalClients(opts, getConf());<a name="line.2389"></a> +<span class="sourceLineNo">2390</span> } else {<a name="line.2390"></a> +<span class="sourceLineNo">2391</span> doMapReduce(opts, getConf());<a name="line.2391"></a> +<span class="sourceLineNo">2392</span> }<a name="line.2392"></a> <span class="sourceLineNo">2393</span> }<a name="line.2393"></a> <span class="sourceLineNo">2394</span><a name="line.2394"></a> -<span class="sourceLineNo">2395</span> protected static void printUsage(final String message) {<a name="line.2395"></a> -<span class="sourceLineNo">2396</span> printUsage(PE_COMMAND_SHORTNAME, message);<a name="line.2396"></a> +<span class="sourceLineNo">2395</span> protected void printUsage() {<a name="line.2395"></a> +<span class="sourceLineNo">2396</span> printUsage(PE_COMMAND_SHORTNAME, null);<a name="line.2396"></a> <span class="sourceLineNo">2397</span> }<a name="line.2397"></a> <span class="sourceLineNo">2398</span><a name="line.2398"></a> -<span class="sourceLineNo">2399</span> protected static void printUsageAndExit(final String message, final int exitCode) {<a name="line.2399"></a> -<span class="sourceLineNo">2400</span> printUsage(message);<a name="line.2400"></a> -<span class="sourceLineNo">2401</span> System.exit(exitCode);<a name="line.2401"></a> -<span class="sourceLineNo">2402</span> }<a name="line.2402"></a> -<span class="sourceLineNo">2403</span><a name="line.2403"></a> -<span class="sourceLineNo">2404</span> protected static void printUsage(final String shortName, final String message) {<a name="line.2404"></a> -<span class="sourceLineNo">2405</span> if (message != null && message.length() > 0) {<a name="line.2405"></a> -<span class="sourceLineNo">2406</span> System.err.println(message);<a name="line.2406"></a> -<span class="sourceLineNo">2407</span> }<a name="line.2407"></a> -<span class="sourceLineNo">2408</span> System.err.print("Usage: hbase " + shortName);<a name="line.2408"></a> -<span class="sourceLineNo">2409</span> System.err.println(" <OPTIONS> [-D<property=value>]* <command> <nclients>");<a name="line.2409"></a> -<span class="sourceLineNo">2410</span> System.err.println();<a name="line.2410"></a> -<span class="sourceLineNo">2411</span> System.err.println("General Options:");<a name="line.2411"></a> -<span class="sourceLineNo">2412</span> System.err.println(" nomapred Run multiple clients using threads " +<a name="line.2412"></a> -<span class="sourceLineNo">2413</span> "(rather than use mapreduce)");<a name="line.2413"></a> -<span class="sourceLineNo">2414</span> System.err.println(" oneCon all the threads share the same connection. Default: False");<a name="line.2414"></a> -<span class="sourceLineNo">2415</span> System.err.println(" connCount connections all threads share. "<a name="line.2415"></a> -<span class="sourceLineNo">2416</span> + "For example, if set to 2, then all thread share 2 connection. "<a name="line.2416"></a> -<span class="sourceLineNo">2417</span> + "Default: depend on oneCon parameter. if oneCon set to true, then connCount=1, "<a name="line.2417"></a> -<span class="sourceLineNo">2418</span> + "if not, connCount=thread number");<a name="line.2418"></a> -<span class="sourceLineNo">2419</span><a name="line.2419"></a> -<span class="sourceLineNo">2420</span> System.err.println(" sampleRate Execute test on a sample of total " +<a name="line.2420"></a> -<span class="sourceLineNo">2421</span> "rows. Only supported by randomRead. Default: 1.0");<a name="line.2421"></a> -<span class="sourceLineNo">2422</span> System.err.println(" period Report every 'period' rows: " +<a name="line.2422"></a> -<span class="sourceLineNo">2423</span> "Default: opts.perClientRunRows / 10 = " + DEFAULT_OPTS.getPerClientRunRows()/10);<a name="line.2423"></a> -<span class="sourceLineNo">2424</span> System.err.println(" cycles How many times to cycle the test. Defaults: 1.");<a name="line.2424"></a> -<span class="sourceLineNo">2425</span> System.err.println(" traceRate Enable HTrace spans. Initiate tracing every N rows. " +<a name="line.2425"></a> -<span class="sourceLineNo">2426</span> "Default: 0");<a name="line.2426"></a> -<span class="sourceLineNo">2427</span> System.err.println(" latency Set to report operation latencies. Default: False");<a name="line.2427"></a> -<span class="sourceLineNo">2428</span> System.err.println(" measureAfter Start to measure the latency once 'measureAfter'" +<a name="line.2428"></a> -<span class="sourceLineNo">2429</span> " rows have been treated. Default: 0");<a name="line.2429"></a> -<span class="sourceLineNo">2430</span> System.err.println(" valueSize Pass value size to use: Default: "<a name="line.2430"></a> -<span class="sourceLineNo">2431</span> + DEFAULT_OPTS.getValueSize());<a name="line.2431"></a> -<span class="sourceLineNo">2432</span> System.err.println(" valueRandom Set if we should vary value size between 0 and " +<a name="line.2432"></a> -<span class="sourceLineNo">2433</span> "'valueSize'; set on read for stats on size: Default: Not set.");<a name="line.2433"></a> -<span class="sourceLineNo">2434</span> System.err.println(" blockEncoding Block encoding to use. Value should be one of "<a name="line.2434"></a> -<span class="sourceLineNo">2435</span> + Arrays.toString(DataBlockEncoding.values()) + ". Default: NONE");<a name="line.2435"></a> -<span class="sourceLineNo">2436</span> System.err.println();<a name="line.2436"></a> -<span class="sourceLineNo">2437</span> System.err.println("Table Creation / Write Tests:");<a name="line.2437"></a> -<span class="sourceLineNo">2438</span> System.err.println(" table Alternate table name. Default: 'TestTable'");<a name="line.2438"></a> -<span class="sourceLineNo">2439</span> System.err.println(" rows Rows each client runs. Default: "<a name="line.2439"></a> -<span class="sourceLineNo">2440</span> + DEFAULT_OPTS.getPerClientRunRows()<a name="line.2440"></a> -<span class="sourceLineNo">2441</span> + ". In case of randomReads and randomSeekScans this could"<a name="line.2441"></a> -<span class="sourceLineNo">2442</span> + " be specified along with --size to specify the number of rows to be scanned within"<a name="line.2442"></a> -<span class="sourceLineNo">2443</span> + " the total range specified by the size.");<a name="line.2443"></a> -<span class="sourceLineNo">2444</span> System.err.println(<a name="line.2444"></a> -<span class="sourceLineNo">2445</span> " size Total size in GiB. Mutually exclusive with --rows for writes and scans"<a name="line.2445"></a> -<span class="sourceLineNo">2446</span> + ". But for randomReads and randomSeekScans when you use size with --rows you could"<a name="line.2446"></a> -<span class="sourceLineNo">2447</span> + " use size to specify the end range and --rows"<a name="line.2447"></a> -<span class="sourceLineNo">2448</span> + " specifies the number of rows within that range. " + "Default: 1.0.");<a name="line.2448"></a> -<span class="sourceLineNo">2449</span> System.err.println(" compress Compression type to use (GZ, LZO, ...). Default: 'NONE'");<a name="line.2449"></a> -<span class="sourceLineNo">2450</span> System.err.println(" flushCommits Used to determine if the test should flush the table. " +<a name="line.2450"></a> -<span class="sourceLineNo">2451</span> "Default: false");<a name="line.2451"></a> -<span class="sourceLineNo">2452</span> System.err.println(" valueZipf Set if we should vary value size between 0 and " +<a name="line.2452"></a> -<span class="sourceLineNo">2453</span> "'valueSize' in zipf form: Default: Not set.");<a name="line.2453"></a> -<span class="sourceLineNo">2454</span> System.err.println(" writeToWAL Set writeToWAL on puts. Default: True");<a name="line.2454"></a> -<span class="sourceLineNo">2455</span> System.err.println(" autoFlush Set autoFlush on htable. Default: False");<a name="line.2455"></a> -<span class="sourceLineNo">2456</span> System.err.println(" multiPut Batch puts together into groups of N. Only supported " +<a name="line.2456"></a> -<span class="sourceLineNo">2457</span> "by write. If multiPut is bigger than 0, autoFlush need to set to true. Default: 0");<a name="line.2457"></a> -<span class="sourceLineNo">2458</span> System.err.println(" presplit Create presplit table. If a table with same name exists,"<a name="line.2458"></a> -<span class="sourceLineNo">2459</span> + " it'll be deleted and recreated (instead of verifying count of its existing regions). "<a name="line.2459"></a> -<span class="sourceLineNo">2460</span> + "Recommended for accurate perf analysis (see guide). Default: disabled");<a name="line.2460"></a> -<span class="sourceLineNo">2461</span> System.err.println(" usetags Writes tags along with KVs. Use with HFile V3. " +<a name="line.2461"></a> -<span class="sourceLineNo">2462</span> "Default: false");<a name="line.2462"></a> -<span class="sourceLineNo">2463</span> System.err.println(" numoftags Specify the no of tags that would be needed. " +<a name="line.2463"></a> -<span class="sourceLineNo">2464</span> "This works only if usetags is true. Default: " + DEFAULT_OPTS.noOfTags);<a name="line.2464"></a> -<span class="sourceLineNo">2465</span> System.err.println(" splitPolicy Specify a custom RegionSplitPolicy for the table.");<a name="line.2465"></a> -<span class="sourceLineNo">2466</span> System.err.println(" columns Columns to write per row. Default: 1");<a name="line.2466"></a> -<span class="sourceLineNo">2467</span> System.err.println(" families Specify number of column families for the table. Default: 1");<a name="line.2467"></a> -<span class="sourceLineNo">2468</span> System.err.println();<a name="line.2468"></a> -<span class="sourceLineNo">2469</span> System.err.println("Read Tests:");<a name="line.2469"></a> -<span class="sourceLineNo">2470</span> System.err.println(" filterAll Helps to filter out all the rows on the server side"<a name="line.2470"></a> -<span class="sourceLineNo">2471</span> + " there by not returning any thing back to the client. Helps to check the server side"<a name="line.2471"></a> -<span class="sourceLineNo">2472</span> + " performance. Uses FilterAllFilter internally. ");<a name="line.2472"></a> -<span class="sourceLineNo">2473</span> System.err.println(" multiGet Batch gets together into groups of N. Only supported " +<a name="line.2473"></a> -<span class="sourceLineNo">2474</span> "by randomRead. Default: disabled");<a name="line.2474"></a> -<span class="sourceLineNo">2475</span> System.err.println(" inmemory Tries to keep the HFiles of the CF " +<a name="line.2475"></a> -<span class="sourceLineNo">2476</span> "inmemory as far as possible. Not guaranteed that reads are always served " +<a name="line.2476"></a> -<span class="sourceLineNo">2477</span> "from memory. Default: false");<a name="line.2477"></a> -<span class="sourceLineNo">2478</span> System.err.println(" bloomFilter Bloom filter type, one of "<a name="line.2478"></a> -<span class="sourceLineNo">2479</span> + Arrays.toString(BloomType.values()));<a name="line.2479"></a> -<span class="sourceLineNo">2480</span> System.err.println(" blockSize Blocksize to use when writing out hfiles. ");<a name="line.2480"></a> -<span class="sourceLineNo">2481</span> System.err.println(" inmemoryCompaction Makes the column family to do inmemory flushes/compactions. "<a name="line.2481"></a> -<span class="sourceLineNo">2482</span> + "Uses the CompactingMemstore");<a name="line.2482"></a> -<span class="sourceLineNo">2483</span> System.err.println(" addColumns Adds columns to scans/gets explicitly. Default: true");<a name="line.2483"></a> -<span class="sourceLineNo">2484</span> System.err.println(" replicas Enable region replica testing. Defaults: 1.");<a name="line.2484"></a> -<span class="sourceLineNo">2485</span> System.err.println(" randomSleep Do a random sleep before each get between 0 and entered value. Defaults: 0");<a name="line.2485"></a> -<span class="sourceLineNo">2486</span> System.err.println(" caching Scan caching to use. Default: 30");<a name="line.2486"></a> -<span class="sourceLineNo">2487</span> System.err.println(" asyncPrefetch Enable asyncPrefetch for scan");<a name="line.2487"></a> -<span class="sourceLineNo">2488</span> System.err.println(" cacheBlocks Set the cacheBlocks option for scan. Default: true");<a name="line.2488"></a> -<span class="sourceLineNo">2489</span> System.err.println(" scanReadType Set the readType option for scan, stream/pread/default. Default: default");<a name="line.2489"></a> -<span class="sourceLineNo">2490</span> System.err.println(" bufferSize Set the value of client side buffering. Default: 2MB");<a name="line.2490"></a> -<span class="sourceLineNo">2491</span> System.err.println();<a name="line.2491"></a> -<span class="sourceLineNo">2492</span> System.err.println(" Note: -D properties will be applied to the conf used. ");<a name="line.2492"></a> -<span class="sourceLineNo">2493</span> System.err.println(" For example: ");<a name="line.2493"></a> -<span class="sourceLineNo">2494</span> System.err.println(" -Dmapreduce.output.fileoutputformat.compress=true");<a name="line.2494"></a> -<span class="sourceLineNo">2495</span> System.err.println(" -Dmapreduce.task.timeout=60000");<a name="line.2495"></a> -<span class="sourceLineNo">2496</span> System.err.println();<a name="line.2496"></a> -<span class="sourceLineNo">2497</span> System.err.println("Command:");<a name="line.2497"></a> -<span class="sourceLineNo">2498</span> for (CmdDescriptor command : COMMANDS.values()) {<a name="line.2498"></a> -<span class="sourceLineNo">2499</span> System.err.println(String.format(" %-20s %s", command.getName(), command.getDescription()));<a name="line.2499"></a> -<span class="sourceLineNo">2500</span> }<a name="line.2500"></a> -<span class="sourceLineNo">2501</span> System.err.println();<a name="line.2501"></a> -<span class="sourceLineNo">2502</span> System.err.println("Args:");<a name="line.2502"></a> -<span class="sourceLineNo">2503</span> System.err.println(" nclients Integer. Required. Total number of clients "<a name="line.2503"></a> -<span class="sourceLineNo">2504</span> + "(and HRegionServers) running. 1 <= value <= 500");<a name="line.2504"></a> -<span class="sourceLineNo">2505</span> System.err.println("Examples:");<a name="line.2505"></a> -<span class="sourceLineNo">2506</span> System.err.println(" To run a single client doing the default 1M sequentialWrites:");<a name="line.2506"></a> -<span class="sourceLineNo">2507</span> System.err.println(" $ hbase " + shortName + " sequentialWrite 1");<a name="line.2507"></a> -<span class="sourceLineNo">2508</span> System.err.println(" To run 10 clients doing increments over ten rows:");<a name="line.2508"></a> -<span class="sourceLineNo">2509</span> System.err.println(" $ hbase " + shortName + " --rows=10 --nomapred increment 10");<a name="line.2509"></a> -<span class="sourceLineNo">2510</span> }<a name="line.2510"></a> -<span class="sourceLineNo">2511</span><a name="line.2511"></a> -<span class="sourceLineNo">2512</span> /**<a name="line.2512"></a> -<span class="sourceLineNo">2513</span> * Parse options passed in via an arguments array. Assumes that array has been split<a name="line.2513"></a> -<span class="sourceLineNo">2514</span> * on white-space and placed into a {@code Queue}. Any unknown arguments will remain<a name="line.2514"></a> -<span class="sourceLineNo">2515</span> * in the queue at the conclusion of this method call. It's up to the caller to deal<a name="line.2515"></a> -<span class="sourceLineNo">2516</span> * with these unrecognized arguments.<a name="line.2516"></a> -<span class="sourceLineNo">2517</span> */<a name="line.2517"></a> -<span class="sourceLineNo">2518</span> static TestOptions parseOpts(Queue<String> args) {<a name="line.2518"></a> -<span class="sourceLineNo">2519</span> TestOptions opts = new TestOptions();<a name="line.2519"></a> -<span class="sourceLineNo">2520</span><a name="line.2520"></a> -<span class="sourceLineNo">2521</span> String cmd = null;<a name="line.2521"></a> -<span class="sourceLineNo">2522</span> while ((cmd = args.poll()) != null) {<a name="line.2522"></a> -<span class="sourceLineNo">2523</span> if (cmd.equals("-h") || cmd.startsWith("--h")) {<a name="line.2523"></a> -<span class="sourceLineNo">2524</span> // place item back onto queue so that caller knows parsing was incomplete<a name="line.2524"></a> -<span class="sourceLineNo">2525</span> args.add(cmd);<a name="line.2525"></a> -<span class="sourceLineNo">2526</span> break;<a name="line.2526"></a> -<span class="sourceLineNo">2527</span> }<a name="line.2527"></a> -<span class="sourceLineNo">2528</span><a name="line.2528"></a> -<span class="sourceLineNo">2529</span> final String nmr = "--nomapred";<a name="line.2529"></a> -<span class="sourceLineNo">2530</span> if (cmd.startsWith(nmr)) {<a name="line.2530"></a> -<span class="sourceLineNo">2531</span> opts.nomapred = true;<a name="line.2531"></a> -<span class="sourceLineNo">2532</span> continue;<a name="line.2532"></a> -<span class="sourceLineNo">2533</span> }<a name="line.2533"></a> -<span class="sourceLineNo">2534</span><a name="line.2534"></a> -<span class="sourceLineNo">2535</span> final String rows = "--rows=";<a name="line.2535"></a> -<span class="sourceLineNo">2536</span> if (cmd.startsWith(rows)) {<a name="line.2536"></a> -<span class="sourceLineNo">2537</span> opts.perClientRunRows = Integer.parseInt(cmd.substring(rows.length()));<a name="line.2537"></a> -<span class="sourceLineNo">2538</span> continue;<a name="line.2538"></a> -<span class="sourceLineNo">2539</span> }<a name="line.2539"></a> -<span class="sourceLineNo">2540</span><a name="line.2540"></a> -<span class="sourceLineNo">2541</span> final String cycles = "--cycles=";<a name="line.2541"></a> -<span class="sourceLineNo">2542</span> if (cmd.startsWith(cycles)) {<a name="line.2542"></a> -<span class="sourceLineNo">2543</span> opts.cycles = Integer.parseInt(cmd.substring(cycles.length()));<a name="line.2543"></a> -<span class="sourceLineNo">2544</span> continue;<a name="line.2544"></a> -<span class="sourceLineNo">2545</span> }<a name="line.2545"></a> -<span class="sourceLineNo">2546</span><a name="line.2546"></a> -<span class="sourceLineNo">2547</span> final String sampleRate = "--sampleRate=";<a name="line.2547"></a> -<span class="sourceLineNo">2548</span> if (cmd.startsWith(sampleRate)) {<a name="line.2548"></a> -<span class="sourceLineNo">2549</span> opts.sampleRate = Float.parseFloat(cmd.substring(sampleRate.length()));<a name="line.2549"></a> -<span class="sourceLineNo">2550</span> continue;<a name="line.2550"></a> -<span class="sourceLineNo">2551</span> }<a name="line.2551"></a> -<span class="sourceLineNo">2552</span><a name="line.2552"></a> -<span class="sourceLineNo">2553</span> final String table = "--table=";<a name="line.2553"></a> -<span class="sourceLineNo">2554</span> if (cmd.startsWith(table)) {<a name="line.2554"></a> -<span class="sourceLineNo">2555</span> opts.tableName = cmd.substring(table.length());<a name="line.2555"></a> -<span class="sourceLineNo">2556</span> continue;<a name="line.2556"></a> -<span class="sourceLineNo">2557</span> }<a name="line.2557"></a> -<span class="sourceLineNo">2558</span><a name="line.2558"></a> -<span class="sourceLineNo">2559</span> final String startRow = "--startRow=";<a name="line.2559"></a> -<span class="sourceLineNo">2560</span> if (cmd.startsWith(startRow)) {<a name="line.2560"></a> -<span class="sourceLineNo">2561</span> opts.startRow = Integer.parseInt(cmd.substring(startRow.length()));<a name="line.2561"></a> -<span class="sourceLineNo">2562</span> continue;<a name="line.2562"></a> -<span class="sourceLineNo">2563</span> }<a name="line.2563"></a> -<span class="sourceLineNo">2564</span><a name="line.2564"></a> -<span class="sourceLineNo">2565</span> final String compress = "--compress=";<a name="line.2565"></a> -<span class="sourceLineNo">2566</span> if (cmd.startsWith(compress)) {<a name="line.2566"></a> -<span class="sourceLineNo">2567</span> opts.compression = Compression.Algorithm.valueOf(cmd.substring(compress.length()));<a name="line.2567"></a> -<span class="sourceLineNo">2568</span> continue;<a name="line.2568"></a> -<span class="sourceLineNo">2569</span> }<a name="line.2569"></a> -<span class="sourceLineNo">2570</span><a name="line.2570"></a> -<span class="sourceLineNo">2571</span> final String traceRate = "--traceRate=";<a name="line.2571"></a> -<span class="sourceLineNo">2572</span> if (cmd.startsWith(traceRate)) {<a name="line.2572"></a> -<span class="sourceLineNo">2573</span> opts.traceRate = Double.parseDouble(cmd.substring(traceRate.length()));<a name="line.2573"></a> -<span class="sourceLineNo">2574</span> continue;<a name="line.2574"></a> -<span class="sourceLineNo">2575</span> }<a name="line.2575"></a> -<span class="sourceLineNo">2576</span><a name="line.2576"></a> -<span class="sourceLineNo">2577</span> final String blockEncoding = "--blockEncoding=";<a name="line.2577"></a> -<span class="sourceLineNo">2578</span> if (cmd.startsWith(blockEncoding)) {<a name="line.2578"></a> -<span class="sourceLineNo">2579</span> opts.blockEncoding = DataBlockEncoding.valueOf(cmd.substring(blockEncoding.length()));<a name="line.2579"></a> -<span class="sourceLineNo">2580</span> continue;<a name="line.2580"></a> -<span class="sourceLineNo">2581</span> }<a name="line.2581"></a> -<span class="sourceLineNo">2582</span><a name="line.2582"></a> -<span class="sourceLineNo">2583</span> final String flushCommits = "--flushCommits=";<a name="line.2583"></a> -<span class="sourceLineNo">2584</span> if (cmd.startsWith(flushCommits)) {<a name="line.2584"></a> -<span class="sourceLineNo">2585</span> opts.flushCommits = Boolean.parseBoolean(cmd.substring(flushCommits.length()));<a name="line.2585"></a> -<span class="sourceLineNo">2586</span> continue;<a name="line.2586"></a> -<span class="sourceLineNo">2587</span> }<a name="line.2587"></a> -<span class="sourceLineNo">2588</span><a name="line.2588"></a> -<span class="sourceLineNo">2589</span> final String writeToWAL = "--writeToWAL=";<a name="line.2589"></a> -<span class="sourceLineNo">2590</span> if (cmd.startsWith(writeToWAL)) {<a name="line.2590"></a> -<span class="sourceLineNo">2591</span> opts.writeToWAL = Boolean.parseBoolean(cmd.substring(writeToWAL.length()));<a name="line.2591"></a> -<span class="sourceLineNo">2592</span> continue;<a name="line.2592"></a> -<span class="sourceLineNo">2593</span> }<a name="line.2593"></a> -<span class="sourceLineNo">2594</span><a name="line.2594"></a> -<span class="sourceLineNo">2595</span> final String presplit = "--presplit=";<a name="line.2595"></a> -<span class="sourceLineNo">2596</span> if (cmd.startsWith(presplit)) {<a name="line.2596"></a> -<span class="sourceLineNo">2597</span> opts.presplitRegions = Integer.parseInt(cmd.substring(presplit.length()));<a name="line.2597"></a> -<span class="sourceLineNo">2598</span> continue;<a name="line.2598"></a> -<span class="sourceLineNo">2599</span> }<a name="line.2599"></a> -<span class="sourceLineNo">2600</span><a name="line.2600"></a> -<span class="sourceLineNo">2601</span> final String inMemory = "--inmemory=";<a name="line.2601"></a> -<span class="sourceLineNo">2602</span> if (cmd.startsWith(inMemory)) {<a name="line.2602"></a> -<span class="sourceLineNo">2603</span> opts.inMemoryCF = Boolean.parseBoolean(cmd.substring(inMemory.length()));<a name="line.2603"></a> -<span class="sourceLineNo">2604</span> continue;<a name="line.2604"></a> -<span class="sourceLineNo">2605</span> }<a name="line.2605"></a> -<span class="sourceLineNo">2606</span><a name="line.2606"></a> -<span class="sourceLineNo">2607</span> final String autoFlush = "--autoFlush=";<a name="line.2607"></a> -<span class="sourceLineNo">2608</span> if (cmd.startsWith(autoFlush)) {<a name="line.2608"></a> -<span class="sourceLineNo">2609</span> opts.autoFlush = Boolean.parseBoolean(cmd.substring(autoFlush.length()));<a name="line.2609"></a> -<span class="sourceLineNo">2610</span> if (!opts.autoFlush && opts.multiPut > 0) {<a name="line.2610"></a> -<span class="sourceLineNo">2611</span> throw new IllegalArgumentException("autoFlush must be true when multiPut is more than 0");<a name="line.2611"></a> -<span class="sourceLineNo">2612</span> }<a name="line.2612"></a> -<span class="sourceLineNo">2613</span> continue;<a name="line.2613"></a> -<span class="sourceLineNo">2614</span> }<a name="line.2614"></a> -<span class="sourceLineNo">2615</span><a name="line.2615"></a> -<span class="sourceLineNo">2616</span> final String onceCon = "--oneCon=";<a name="line.2616"></a> -<span class="sourceLineNo">2617</span> if (cmd.startsWith(onceCon)) {<a name="line.2617"></a> -<span class="sourceLineNo">2618</span> opts.oneCon = Boolean.parseBoolean(cmd.substring(onceCon.length()));<a name="line.2618"></a> -<span class="sourceLineNo">2619</span> if (opts.oneCon && opts.connCount > 1) {<a name="line.2619"></a> -<span class="sourceLineNo">2620</span> throw new IllegalArgumentException("oneCon is set to true, "<a name="line.2620"></a> -<span class="sourceLineNo">2621</span> + "connCount should not bigger than 1");<a name="line.2621"></a> -<span class="sourceLineNo">2622</span> }<a name="line.2622"></a> -<span class="sourceLineNo">2623</span> continue;<a name="line.2623"></a> -<span class="sourceLineNo">2624</span> }<a name="line.2624"></a> -<span class="sourceLineNo">2625</span><a name="line.2625"></a> -<span class="sourceLineNo">2626</span> final String connCount = "--connCount=";<a name="line.2626"></a> -<span class="sourceLineNo">2627</span> if (cmd.startsWith(connCount)) {<a name="line.2627"></a> -<span class="sourceLineNo">2628</span> opts.connCount = Integer.parseInt(cmd.substring(connCount.length()));<a name="line.2628"></a> -<span class="sourceLineNo">2629</span> if (opts.oneCon && opts.connCount > 1) {<a name="line.2629"></a> -<span class="sourceLineNo">2630</span> throw new IllegalArgumentException("oneCon is set to true, "<a name="line.2630"></a> -<span class="sourceLineNo">2631</span> + "connCount should not bigger than 1");<a name="line.2631"></a> -<span class="sourceLineNo">2632</span> }<a name="line.2632"></a> -<span class="sourceLineNo">2633</span> continue;<a name="line.2633"></a> -<span class="sourceLineNo">2634</span> }<a name="line.2634"></a> -<span class="sourceLineNo">2635</span><a name="line.2635"></a> -<span class="sourceLineNo">2636</span> final String latency = "--latency";<a name="line.2636"></a> -<span class="sourceLineNo">2637</span> if (cmd.startsWith(latency)) {<a name="line.2637"></a> -<span class="sourceLineNo">2638</span> opts.reportLatency = true;<a name="line.2638"></a> -<span class="sourceLineNo">2639</span> continue;<a name="line.2639"></a> -<span class="sourceLineNo">2640</span> }<a name="line.2640"></a> -<span class="sourceLineNo">2641</span><a name="line.2641"></a> -<span class="sourceLineNo">2642</span> final String multiGet = "--multiGet=";<a name="line.2642"></a> -<span class="sourceLineNo">2643</span> if (cmd.startsWith(multiGet)) {<a name="line.2643"></a> -<span class="sourceLineNo">2644</span> opts.multiGet = Integer.parseInt(cmd.substring(multiGet.length()));<a name="line.2644"></a> -<span class="sourceLineNo">2645</span> continue;<a name="line.2645"></a> -<span class="sourceLineNo">2646</span> }<a name="line.2646"></a> -<span class="sourceLineNo">2647</span><a name="line.2647"></a> -<span class="sourceLineNo">2648</span> final String multiPut = "--multiPut=";<a name="line.2648"></a> -<span class="sourceLineNo">2649</span> if (cmd.startsWith(multiPut)) {<a name="line.2649"></a> -<span class="sourceLineNo">2650</span> opts.multiPut = Integer.parseInt(cmd.substring(multiPut.length()));<a name="line.2650"></a> -<span class="sourceLineNo">2651</span> if (!opts.autoFlush && opts.multiPut > 0) {<a name="line.2651"></a> -<span class="sourceLineNo">2652</span> throw new IllegalArgumentException("autoFlush must be true when multiPut is more than 0");<a name="line.2652"></a> -<span class="sourceLineNo">2653</span> }<a name="line.2653"></a> -<span class="sourceLineNo">2654</span> continue;<a name="line.2654"></a> -<span class="sourceLineNo">2655</span> }<a name="line.2655"></a> -<span class="sourceLineNo">2656</span><a name="line.2656"></a> -<span class="sourceLineNo">2657</span> final String useTags = "--usetags=";<a name="line.2657"></a> -<span class="sourceLineNo">2658</span> if (cmd.startsWith(useTags)) {<a name="line.2658"></a> -<span class="sourceLineNo">2659</span> opts.useTags = Boolean.parseBoolean(cmd.substring(useTags.length()));<a name="line.2659"></a> -<span class="sourceLineNo">2660</span> continue;<a name="line.2660"></a> -<span class="sourceLineNo">2661</span> }<a name="line.2661"></a> -<span class="sourceLineNo">2662</span><a name="line.2662"></a> -<span class="sourceLineNo">2663</span> final String noOfTags = "--numoftags=";<a name="line.2663"></a> -<span class="sourceLineNo">2664</span> if (cmd.startsWith(noOfTags)) {<a name="line.2664"></a> -<span class="sourceLineNo">2665</span> opts.noOfTags = Integer.parseInt(cmd.substring(noOfTags.length()));<a name="line.2665"></a> -<span class="sourceLineNo">2666</span> continue;<a name="line.2666"></a> -<span class="sourceLineNo">2667</span> }<a name="line.2667"></a> -<span class="sourceLineNo">2668</span><a name="line.2668"></a> -<span class="sourceLineNo">2669</span> final String replicas = "--replicas=";<a name="line.2669"></a> -<span class="sourceLineNo">2670</span> if (cmd.startsWith(replicas)) {<a name="line.2670"></a> -<span class="sourceLineNo">2671</span> opts.replicas = Integer.parseInt(cmd.substring(replicas.length()));<a name="line.2671"></a> -<span class="sourceLineNo">2672</span> continue;<a name="line.2672"></a> -<span class="sourceLineNo">2673</span> }<a name="line.2673"></a> -<span class="sourceLineNo">2674</span><a name="line.2674"></a> -<span class="sourceLineNo">2675</span> final String filterOutAll = "--filterAll";<a name="line.2675"></a> -<span class="sourceLineNo">2676</span> if (cmd.startsWith(filterOutAll)) {<a name="line.2676"></a> -<span class="sourceLineNo">2677</span> opts.filterAll = true;<a name="line.2677"></a> -<span class="sourceLineNo">2678</span> continue;<a name="line.2678"></a> -<span class="sourceLineNo">2679</span> }<a name="line.2679"></a> -<span class="sourceLineNo">2680</span><a name="line.2680"></a> -<span class="sourceLineNo">2681</span> final String size = "--size=";<a name="line.2681"></a> -<span class="sourceLineNo">2682</span> if (cmd.startsWith(size)) {<a name="line.2682"></a> -<span class="sourceLineNo">2683</span> opts.size = Float.parseFloat(cmd.substring(size.length()));<a name="line.2683"></a> -<span class="sourceLineNo">2684</span> if (opts.size <= 1.0f) throw new IllegalStateException("Size must be > 1; i.e. 1GB");<a name="line.2684"></a> -<span class="sourceLineNo">2685</span> continue;<a name="line.2685"></a> -<span class="sourceLineNo">2686</span> }<a name="line.2686"></a> -<span class="sourceLineNo">2687</span><a name="line.2687"></a> -<span class="sourceLineNo">2688</span> final String splitPolicy = "--splitPolicy=";<a name="line.2688"></a> -<span class="sourceLineNo">2689</span> if (cmd.startsWith(splitPolicy)) {<a name="line.2689"></a> -<span class="sourceLineNo">2690</span> opts.splitPolicy = cmd.substring(splitPolicy.length());<a name="line.2690"></a> -<span class="sourceLineNo">2691</span> continue;<a name="line.2691"></a> -<span class="sourceLineNo">2692</span> }<a name="line.2692"></a> -<span class="sourceLineNo">2693</span><a name="line.2693"></a> -<span class="sourceLineNo">2694</span> final String randomSleep = "--randomSleep=";<a name="line.2694"></a> -<span class="sourceLineNo">2695</span> if (cmd.startsWith(randomSleep)) {<a name="line.2695"></a> -<span class="sourceLineNo">2696</span> opts.randomSleep = Integer.parseInt(cmd.substring(randomSleep.length()));<a name="line.2696"></a> -<span class="sourceLineNo">2697</span> continue;<a name="line.2697"></a> -<span class="sourceLineNo">2698</span> }<a name="line.2698"></a> -<span class="sourceLineNo">2699</span><a name="line.2699"></a> -<span class="sourceLineNo">2700</span> final String measureAfter = "--measureAfter=";<a name="line.2700"></a> -<span class="sourceLineNo">2701</span> if (cmd.startsWith(measureAfter)) {<a name="line.2701"></a> -<span class="sourceLineNo">2702</span> opts.measureAfter = Integer.parseInt(cmd.substring(measureAfter.length()));<a name="line.2702"></a> -<span class="sourceLineNo">2703</span> continue;<a name="line.2703"></a> -<span class="sourceLineNo">2704</span> }<a name="line.2704"></a> -<span class="sourceLineNo">2705</span><a name="line.2705"></a> -<span class="sourceLineNo">2706</span> final String bloomFilter = "--bloomFilter=";<a name="line.2706"></a> -<span class="sourceLineNo">2707</span> if (cmd.startsWith(bloomFilter)) {<a name="line.2707"></a> -<span class="sourceLineNo">2708</span> opts.bloomType = BloomType.valueOf(cmd.substring(bloomFilter.length()));<a name="line.2708"></a> -<span class="sourceLineNo">2709</span> continue;<a name="line.2709"></a> -<span class="sourceLineNo">2710</span> }<a name="line.2710"></a> -<span class="sourceLineNo">2711</span><a name="line.2711"></a> -<span class="sourceLineNo">2712</span> final String blockSize = "--blockSize=";<a name="line.2712"></a> -<span class="sourceLineNo">2713</span> if(cmd.startsWith(blockSize) ) {<a name="line.2713"></a> -<span class="sourceLineNo">2714</span> opts.blockSize = Integer.parseInt(cmd.substring(blockSize.length()));<a name="line.2714"></a> -<span class="sourceLineNo">2715</span> }<a name="line.2715"></a> -<span class="sourceLineNo">2716</span><a name="line.2716"></a> -<span class="sourceLineNo">2717</span> final String valueSize = "--valueSize=";<a name="line.2717"></a> -<span class="sourceLineNo">2718</span> if (cmd.startsWith(valueSize)) {<a name="line.2718"></a> -<span class="sourceLineNo">2719</span> opts.valueSize = Integer.parseInt(cmd.substring(valueSize.length()));<a name="line.2719"></a> -<span class="sourceLineNo">2720</span> continue;<a name="line.2720"></a> -<span class="sourceLineNo">2721</span> }<a name="line.2721"></a> -<span class="sourceLineNo">2722</span><a name="line.2722"></a> -<span class="sourceLineNo">2723</span> final String valueRandom = "--valueRandom";<a name="line.2723"></a> -<span class="sourceLineNo">2724</span> if (cmd.startsWith(valueRandom)) {<a name="line.2724"></a> -<span class="sourceLineNo">2725</span> opts.valueRandom = true;<a name="line.2725"></a> -<span class="sourceLineNo">2726</span> if (opts.valueZipf) {<a name="line.2726"></a> -<span class="sourceLineNo">2727</span> throw new IllegalStateException("Either valueZipf or valueRandom but not both");<a name="line.2727"></a> -<span class="sourceLineNo">2728</span> }<a name="line.2728"></a> -<span class="sourceLineNo">2729</span> continue;<a name="line.2729"></a> -<span class="sourceLineNo">2730</span> }<a name="line.2730"></a> -<span class="sourceLineNo">2731</span><a name="line.2731"></a> -<span class="sourceLineNo">2732</span> final String valueZipf = "--valueZipf";<a name="line.2732"></a> -<span class="sourceLineNo">2733</span> if (cmd.startsWith(valueZipf)) {<a name="line.2733"></a> -<span class="sourceLineNo">2734</span> opts.valueZipf = true;<a name="line.2734"></a> -<span class="sourceLineNo">2735</span> if (opts.valueRandom) {<a name="line.2735"></a> -<span class="sourceLineNo">2736</span> throw new IllegalStateException("Either valueZipf or valueRandom but not both");<a name="line.2736"></a> -<span class="sourceLineNo">2737</span> }<a name="line.2737"></a> -<span class="sourceLineNo">2738</span> continue;<a name="line.2738"></a> -<span class="sourceLineNo">2739</span> }<a name="line.2739"></a> -<span class="sourceLineNo">2740</span><a name="line.2740"></a> -<span class="sourceLineNo">2741</span> final String period = "--period=";<a name="line.2741"></a> -<span class="sourceLineNo">2742</span> if (cmd.startsWith(period)) {<a name="line.2742"></a> -<span class="sourceLineNo">2743</span> opts.period = Integer.parseInt(cmd.substring(period.length()));<a name="line.2743"></a> -<span class="sourceLineNo">2744</span> continue;<a name="line.2744"></a> -<span class="sourceLineNo">2745</span> }<a name="line.2745"></a> -<span class="sourceLineNo">2746</span><a name="line.2746"></a> -<span class="sourceLineNo">2747</span> final String addColumns = "--addColumns=";<a name="line.2747"></a> -<span class="sourceLineNo">2748</span> if (cmd.startsWith(addColumns)) {<a name="line.2748"></a> -<span class="sourceLineNo">2749</span> opts.addColumns = Boolean.parseBoolean(cmd.substring(addColumns.length()));<a name="line.2749"></a> -<span class="sourceLineNo">2750</span> continue;<a name="line.2750"></a> -<span class="sourceLineNo">2751</span> }<a name="line.2751"></a> -<span class="sourceLineNo">2752</span><a name="line.2752"></a> -<span class="sourceLineNo">2753</span> final String inMemoryCompaction = "--inmemoryCompaction=";<a name="line.2753"></a> -<span class="sourceLineNo">2754</span> if (cmd.startsWith(inMemoryCompaction)) {<a name="line.2754"></a> -<span class="sourceLineNo">2755</span> opts.inMemoryCompaction =<a name="line.2755"></a> -<span class="sourceLineNo">2756</span> MemoryCompactionPolicy.valueOf(cmd.substring(inMemoryCompaction.length()));<a name="line.2756"></a> -<span class="sourceLineNo">2757</span> continue;<a name="line.2757"></a> -<span class="sourceLineNo">2758</span> }<a name="line.2758"></a> -<span class="sourceLineNo">2759</span><a name="line.2759"></a> -<span class="sourceLineNo">2760</span> final String columns = "--columns=";<a name="line.2760"></a> -<span class="sourceLineNo">2761</span> if (cmd.startsWith(columns)) {<a name="line.2761"></a> -<span class="sourceLineNo">2762</span> opts.columns = Integer.parseInt(cmd.substring(columns.length()));<a name="line.2762"></a> -<span class="sourceLineNo">2763</span> continue;<a name="line.2763"></a> -<span class="sourceLineNo">2764</span> }<a name="line.2764"></a> -<span class="sourceLineNo">2765</span><a name="line.2765"></a> -<span class="sourceLineNo">2766</span> final String families = "--families=";<a name="line.2766"></a> -<span class="sourceLineNo">2767</span> if (cmd.startsWith(families)) {<a name="line.2767"></a> -<span class="sourceLineNo">2768</span> opts.families = Integer.parseInt(cmd.substring(families.length()));<a name="line.2768"></a> -<span class="sourceLineNo">2769</span> continue;<a name="line.2769"></a> -<span class="sourceLineNo">2770</span> }<a name="line.2770"></a> -<span class="sourceLineNo">2771</span><a name="line.2771"></a> -<span class="sourceLineNo">2772</span> final String caching = "--caching=";<a name="line.2772"></a> -<span class="sourceLineNo">2773</span> if (cmd.startsWith(caching)) {<a name="line.2773"></a> -<span class="sourceLineNo">2774</span> opts.caching = Integer.parseInt(cmd.substring(caching.length()));<a name="line.2774"></a> -<span class="sourceLineNo">2775</span> continue;<a name="line.2775"></a> -<span class="sourceLineNo">2776</span> }<a name="line.2776"></a> -<span class="sourceLineNo">2777</span><a name="line.2777"></a> -<span class="sourceLineNo">2778</span> final String asyncPrefetch = "--asyncPrefetch";<a name="line.2778"></a> -<span class="sourceLineNo">2779</span> if (cmd.startsWith(asyncPrefetch)) {<a name="line.2779"></a> -<span class="sourceLineNo">2780</span> opts.asyncPrefetch = true;<a name="line.2780"></a> -<span class="sourceLineNo">2781</span> continue;<a name="line.2781"></a> -<span class="sourceLineNo">2782</span> }<a name="line.2782"></a> -<span class="sourceLineNo">2783</span><a name="line.2783"></a> -<span class="sourceLineNo">2784</span> final String cacheBlocks = "--cacheBlocks=";<a name="line.2784"></a> -<span class="sourceLineNo">2785</span> if (cmd.startsWith(cacheBlocks)) {<a name="line.2785"></a> -<span class="sourceLineNo">2786</span> opts.cacheBlocks = Boolean.parseBoolean(cmd.substring(cacheBlocks.length()));<a name="line.2786"></a> -<span class="sourceLineNo">2787</span> continue;<a name="line.2787"></a> -<span class="sourceLineNo">2788</span> }<a name="line.2788"></a> -<span class="sourceLineNo">2789</span><a name="line.2789"></a> -<span class="sourceLineNo">2790</span> final String scanReadType = "--scanReadType=";<a name="line.2790"></a> -<span class="sourceLineNo">2791</span> if (cmd.startsWith(scanReadType)) {<a name="line.2791"></a> -<span class="sourceLineNo">2792</span> opts.scanReadType =<a name="line.2792"></a> -<span class="sourceLineNo">2793</span> Scan.ReadType.valueOf(cmd.substring(scanReadType.length()).toUpperCase());<a name="line.2793"></a> -<span class="sourceLineNo">2794</span> continue;<a name="line.2794"></a> -<span class="sourceLineNo">2795</span> }<a name="line.2795"></a> -<span class="sourceLineNo">2796</span><a name="line.2796"></a> -<span class="sourceLineNo">2797</span> final String bufferSize = "--bufferSize=";<a name="line.2797"></a> -<span class="sourceLineNo">2798</span> if (cmd.startsWith(bufferSize)) {<a name="line.2798"></a> -<span class="sourceLineNo">2799</span> opts.bufferSize = Long.parseLong(cmd.substring(bufferSize.length()));<a name="line.2799"></a> -<span class="sourceLineNo">2800</span> continue;<a name="line.2800"></a> -<span class="sourceLineNo">2801</span> }<a name="line.2801"></a> -<span class="sourceLineNo">2802</span><a name="line.2802"></a> -<span class="sourceLineNo">2803</span> if (isCommandClass(cmd)) {<a name="line.2803"></a> -<span class="sourceLineNo">2804</span> opts.cmdName = cmd;<a name="line.2804"></a> -<span class="sourceLineNo">2805</span> try {<a name="line.2805"></a> -<span class="sourceLineNo">2806</span> opts.numClientThreads = Integer.parseInt(args.remove());<a name="line.2806"></a> -<span class="sourceLineNo">2807</span> } catch (NoSuchElementException | NumberFormatException e) {<a name="line.2807"></a> -<span class="sourceLineNo">2808</span> throw new IllegalArgumentException("Command " + cmd + " does not have threads number", e);<a name="line.2808"></a> -<span class="sourceLineNo">2809</span> }<a name="line.2809"></a> -<span class="sourceLineNo">2810</span> opts = calculateRowsAndSize(opts);<a name="line.2810"></a> -<span class="sourceLineNo">2811</span> break;<a name="line.2811"></a> -<span class="sourceLineNo">2812</span> } else {<a name="line.2812"></a> -<span class="sourceLineNo">2813</span> printUsageAndExit("ERROR: Unrecognized option/command: " + cmd, -1);<a name="line.2813"></a> -<span class="sourceLineNo">2814</span> }<a name="line.2814"></a> -<span class="sourceLineNo">2815</span><a name="line.2815"></a> -<span class="sourceLineNo">2816</span> // Not matching any option or command.<a name="line.2816"></a> -<span class="sourceLineNo">2817</span> System.err.println("Error: Wrong option or command: " + cmd);<a name="line.2817"></a> -<span class="sourceLineNo">2818</span> args.add(cmd);<a name="line.2818"></a> -<span class="sourceLineNo">2819</span> break;<a name="line.2819"></a> -<span class="sourceLineNo">2820</span> }<a name="line.2820"></a> -<span class="sourceLineNo">2821</span> return opts;<a name="line.2821"></a> -<span class="sourceLineNo">2822</span> }<a name="line.2822"></a> -<span class="sourceLineNo">2823</span><a name="line.2823"></a> -<span class="sourceLineNo">2824</span> static TestOptions calculateRowsAndSize(final TestOptions opts) {<a name="line.2824"></a> -<span class="sourceLineNo">2825</span> int rowsPerGB = getRowsPerGB(opts);<a name="line.2825"></a> -<span class="sourceLineNo">2826</span> if ((opts.getCmdName() != null<a name="line.2826"></a> -<span class="sourceLineNo">2827</span> && (opts.getCmdName().equals(RANDOM_READ) || opts.getCmdName().equals(RANDOM_SEEK_SCAN)))<a name="line.2827"></a> -<span class="sourceLineNo">2828</span> && opts.size != DEFAULT_OPTS.size<a name="line.2828"></a> -<span class="sourceLineNo">2829</span> && opts.perClientRunRows != DEFAULT_OPTS.perClientRunRows) {<a name="line.2829"></a> -<span class="sourceLineNo">2830</span> opts.totalRows = (int) opts.size * rowsPerGB;<a name="line.2830"></a> -<span class="sourceLineNo">2831</span> } else if (opts.size != DEFAULT_OPTS.size) {<a name="line.2831"></a> -<span class="sourceLineNo">2832</span> // total size in GB specified<a name="line.2832"></a> -<span class="sourceLineNo">2833</span> opts.totalRows = (int) opts.size * rowsPerGB;<a name="line.2833"></a> -<span class="sourceLineNo">2834</span> opts.perClientRunRows = opts.totalRows / opts.numClientThreads;<a name="line.2834"></a> -<span class="sourceLineNo">2835</span> } else {<a name="line.2835"></a> -<span class="sourceLineNo">2836</span> opts.totalRows = opts.perClientRunRows * opts.numClientThreads;<a name="line.2836"></a> -<span class="sourceLineNo">2837</span> opts.size = opts.totalRows / rowsPerGB;<a name="line.2837"></a> -<span class="sourceLineNo">2838</span> }<a name="line.2838"></a> -<span class="sourceLineNo">2839</span> return opts;<a name="line.2839"></a> -<span class="sourceLineNo">2840</span> }<a name="line.2840"></a> -<span class="sourceLineNo">2841</span><a name="line.2841"></a> -<span class="sourceLineNo">2842</span> static int getRowsPerGB(final TestOptions opts) {<a name="line.2842"></a> -<span class="sourceLineNo">2843</span> return ONE_GB / ((opts.valueRandom? opts.valueSize/2: opts.valueSize) * opts.getFamilies() *<a name="line.2843"></a> -<span class="sourceLineNo">2844</span> opts.getColumns());<a name="line.2844"></a> -<span class="sourceLineNo">2845</span> }<a name="line.2845"></a> -<span class="sourceLineNo">2846</span><a name="line.2846"></a> -<span class="sourceLineNo">2847</span> @Override<a name="line.2847"></a> -<span class="sourceLineNo">2848</span> public int run(String[] args) throws Exception {<a name="line.2848"></a> -<span class="sourceLineNo">2849</span> // Process command-line args. TODO: Better cmd-line processing<a name="line.2849"></a> -<span class="sourceLineNo">2850</span> // (but hopefully something not as painful as cli options).<a name="line.2850"></a> -<span class="sourceLineNo">2851</span> int errCode = -1;<a name="line.2851"></a> -<span class="sourceLineNo">2852</span> if (args.length < 1) {<a name="line.2852"></a> -<span class="sourceLineNo">2853</span> printUsage();<a name="line.2853"></a> -<span class="sourceLineNo">2854</span> return errCode;<a name="line.2854"></a> -<span class="sourceLineNo">2855</span> }<a name="line.2855"></a> -<span class="sourceLineNo">2856</span><a name="line.2856"></a> -<span class="sourceLineNo">2857</span> try {<a name="line.2857"></a> -<span class="sourceLineNo">2858</span> LinkedList<String> argv = new LinkedList<>();<a name="line.2858"></a> -<span class="sourceLineNo">2859</span> argv.addAll(Arrays.asList(args));<a name="line.2859"></a> -<span class="sourceLineNo">2860</span> TestOptions opts = parseOpts(argv);<a name="line.2860"></a> -<span class="sourceLineNo">2861</span><a name="line.2861"></a> -<span class="sourceLineNo">2862</span> // args remaining, print help and exit<a name="line.2862"></a> -<span class="sourceLineNo">2863</span> if (!argv.isEmpty()) {<a name="line.2863"></a> -<span class="sourceLineNo">2864</span> errCode = 0;<a name="line.2864"></a> -<span class="sourceLineNo">2865</span> printUsage();<a name="line.2865"></a> -<span class="sourceLineNo">2866</span> return errCode;<a name="line.2866"></a> -<span class="sourceLineNo">2867</span> }<a name="line.2867"></a> -<span class="sourceLineNo">2868</span><a name="line.2868"></a> -<span class="sourceLineNo">2869</span> // must run at least 1 client<a name="line.2869"></a> -<span class="sourceLineNo">2870</span> if (opts.numClientThreads <= 0) {<a name="line.2870"></a> -<span class="sourceLineNo">2871</span> throw new IllegalArgumentException("Number of clients must be > 0");<a name="line.2871"></a> -<span class="sourceLineNo">2872</span> }<a name="line.2872"></a> -<span class="sourceLineNo">2873</span><a name="line.2873"></a> -<span class="sourceLineNo">2874</span> // cmdName should not be null, print help and exit<a name="line.2874"></a> -<span class="sourceLineNo">2875</span> if (opts.cmdName == null) {<a name="line.2875"></a> -<span class="sourceLineNo">2876</span> printUsage();<a name="line.2876"></a> -<span class="sourceLineNo">2877</span> return errCode;<a name="line.2877"></a> -<span class="sourceLineNo">2878</span> }<a name="line.2878"></a> -<span class="sourceLineNo">2879</span><a name="line.2879"></a> -<span class="sourceLineNo">2880</span> Class<? extends TestBase> cmdClass = determineCommandClass(opts.cmdName);<a name="line.2880"></a> -<span class="sourceLineNo">2881</span> if (cmdClass != null) {<a name="line.2881"></a> -<span class="sourceLineNo">2882</span> runTest(cmdClass, opts);<a name="line.2882"></a> -<span class="sourceLineNo">2883</span> errCode = 0;<a name="line.2883"></a> -<span class="sourceLineNo">2884</span> }<a name="line.2884"></a> -<span class="sourceLineNo">2885</span><a name="line.2885"></a> -<span class="sourceLineNo">2886</span> } catch (Exception e) {<a name="line.2886"></a> -<span class="sourceLineNo">2887</span> e.printStackTrace();<a name="line.2887"></a> -<span class="sourceLineNo">2888</span> }<a name="line.2888"></a> +<span class="sourceLineNo">2399</span> protected static void printUsage(final String message) {<a name="line.2399"></a> +<span class="sourceLineNo">2400</span> printUsage(PE_COMMAND_SHORTNAME, message);<a name="line.2400"></a> +<span class="sourceLineNo">2401</span> }<a name="line.2401"></a> +<span class="sourceLineNo">2402</span><a name="line.2402"></a> +<span class="sourceLineNo">2403</span> protected static void printUsageAndExit(final String message, final int exitCode) {<a name="line.2403"></a> +<span class="sourceLineNo">2404</span> printUsage(message);<a name="line.2404"></a> +<span class="sourceLineNo">2405</span> System.exit(exitCode);<a name="line.2405"></a> +<span class="sourceLineNo">2406</span> }<a name="line.2406"></a> +<span class="sourceLineNo">2407</span><a name="line.2407"></a> +<span class="sourceLineNo">2408</span> protected static void printUsage(final String shortName, final String message) {<a name="line.2408"></a> +<span class="sourceLineNo">2409</span> if (message != null && message.length() > 0) {<a name="line.2409"></a> +<span class="sourceLineNo">2410</span> System.err.println(message);<a name="line.2410"></a> +<span class="sourceLineNo">2411</span> }<a name="line.2411"></a> +<span class="sourceLineNo">2412</span> System.err.print("Usage: hbase " + shortName);<a name="line.2412"></a> +<span class="sourceLineNo">2413</span> System.err.println(" <OPTIONS> [-D<property=value>]* <command> <nclients>");<a name="line.2413"></a> +<span class="sourc
<TRUNCATED>