From e0c1256a270fd60f0b23d1acd4e389a30998a656 Mon Sep 17 00:00:00 2001 From: zhangduo Date: Mon, 17 Apr 2017 16:20:45 +0800 Subject: [PATCH] HBASE-17929 Add more options for PE tool --- .../apache/hadoop/hbase/PerformanceEvaluation.java | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java index 40e50cf..96ee515 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java @@ -636,6 +636,8 @@ public class PerformanceEvaluation extends Configured implements Tool { MemoryCompactionPolicy inMemoryCompaction = MemoryCompactionPolicy.valueOf( CompactingMemStore.COMPACTING_MEMSTORE_TYPE_DEFAULT); + boolean asyncPrefetch = false; + boolean cacheBlocks = true; public TestOptions() {} @@ -1246,8 +1248,9 @@ public class PerformanceEvaluation extends Configured implements Tool { @Override void testRow(final int i) throws IOException { - Scan scan = new Scan(getRandomRow(this.rand, opts.totalRows)); - scan.setCaching(opts.caching); + Scan scan = + new Scan().withStartRow(getRandomRow(this.rand, opts.totalRows)).setCaching(opts.caching) + .setCacheBlocks(opts.cacheBlocks).setAsyncPrefetch(opts.asyncPrefetch); FilterList list = new FilterList(); if (opts.addColumns) { scan.addColumn(FAMILY_NAME, QUALIFIER_NAME); @@ -1282,8 +1285,9 @@ public class PerformanceEvaluation extends Configured implements Tool { @Override void testRow(final int i) throws IOException { Pair startAndStopRow = getStartAndStopRow(); - Scan scan = new Scan(startAndStopRow.getFirst(), startAndStopRow.getSecond()); - scan.setCaching(opts.caching); + Scan scan = new Scan().withStartRow(startAndStopRow.getFirst()) + .withStopRow(startAndStopRow.getSecond()).setCaching(opts.caching) + .setCacheBlocks(opts.cacheBlocks).setAsyncPrefetch(opts.asyncPrefetch); if (opts.filterAll) { scan.setFilter(new FilterAllFilter()); } @@ -1477,8 +1481,8 @@ public class PerformanceEvaluation extends Configured implements Tool { @Override void testRow(final int i) throws IOException { if (this.testScanner == null) { - Scan scan = new Scan(format(opts.startRow)); - scan.setCaching(opts.caching); + Scan scan = new Scan().withStartRow(format(opts.startRow)).setCaching(opts.caching) + .setCacheBlocks(opts.cacheBlocks).setAsyncPrefetch(opts.asyncPrefetch); if (opts.addColumns) { scan.addColumn(FAMILY_NAME, QUALIFIER_NAME); } else { @@ -1487,7 +1491,7 @@ public class PerformanceEvaluation extends Configured implements Tool { if (opts.filterAll) { scan.setFilter(new FilterAllFilter()); } - this.testScanner = table.getScanner(scan); + this.testScanner = table.getScanner(scan); } Result r = testScanner.next(); updateValueSize(r); @@ -1687,8 +1691,8 @@ public class PerformanceEvaluation extends Configured implements Tool { if(opts.filterAll) { list.addFilter(new FilterAllFilter()); } - Scan scan = new Scan(); - scan.setCaching(opts.caching); + Scan scan = new Scan().setCaching(opts.caching).setCacheBlocks(opts.cacheBlocks) + .setAsyncPrefetch(opts.asyncPrefetch); if (opts.addColumns) { scan.addColumn(FAMILY_NAME, QUALIFIER_NAME); } else { @@ -2138,8 +2142,8 @@ public class PerformanceEvaluation extends Configured implements Tool { final String inMemoryCompaction = "--inmemoryCompaction="; if (cmd.startsWith(inMemoryCompaction)) { - opts.inMemoryCompaction = opts.inMemoryCompaction.valueOf(cmd.substring - (inMemoryCompaction.length())); + opts.inMemoryCompaction = + MemoryCompactionPolicy.valueOf(cmd.substring(inMemoryCompaction.length())); continue; } @@ -2155,6 +2159,17 @@ public class PerformanceEvaluation extends Configured implements Tool { continue; } + final String asyncPrefetch = "--asyncPrefetch"; + if (cmd.startsWith(asyncPrefetch)) { + opts.asyncPrefetch = true; + continue; + } + + final String cacheBlocks = "--cacheBlocks="; + if (cmd.startsWith(cacheBlocks)) { + opts.cacheBlocks = Boolean.parseBoolean(cmd.substring(cacheBlocks.length())); + continue; + } if (isCommandClass(cmd)) { opts.cmdName = cmd; try { -- 2.7.4