From 62e1137c94cbcc7976450dbb1bc9a5fb3cfd6d37 Mon Sep 17 00:00:00 2001 From: ramkrishna Date: Thu, 23 May 2013 17:05:42 +0000 Subject: [PATCH] HBASE-8235-Adding inmemory CF attribute to LoadTest and PerformanceEvaluation tool (Ram) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1485779 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/PerformanceEvaluation.java | 15 ++++++++++++++- .../apache/hadoop/hbase/util/LoadTestTool.java | 13 ++++++++++++- 2 files changed, 26 insertions(+), 2 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 8b8bac30f30..15710da2c99 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 @@ -131,6 +131,7 @@ public class PerformanceEvaluation extends Configured implements Tool { private DataBlockEncoding blockEncoding = DataBlockEncoding.NONE; private boolean flushCommits = true; private boolean writeToWAL = true; + private boolean inMemoryCF = false; private int presplitRegions = 0; private static final Path PERF_EVAL_DIR = new Path("performance_evaluation"); @@ -510,6 +511,9 @@ public class PerformanceEvaluation extends Configured implements Tool { HColumnDescriptor family = new HColumnDescriptor(FAMILY_NAME); family.setDataBlockEncoding(blockEncoding); family.setCompressionType(compression); + if (inMemoryCF) { + family.setInMemory(true); + } TABLE_DESCRIPTOR.addFamily(family); } return TABLE_DESCRIPTOR; @@ -1292,6 +1296,9 @@ public class PerformanceEvaluation extends Configured implements Tool { System.err.println(" flushCommits Used to determine if the test should flush the table. Default: false"); System.err.println(" writeToWAL Set writeToWAL on puts. Default: True"); System.err.println(" presplit Create presplit table. Recommended for accurate perf analysis (see guide). Default: disabled"); + System.err + .println(" inmemory Tries to keep the HFiles of the CF inmemory as far as possible. Not " + + "guaranteed that reads are always served from inmemory. Default: false"); System.err.println(); System.err.println(" Note: -D properties will be applied to the conf used. "); System.err.println(" For example: "); @@ -1396,7 +1403,13 @@ public class PerformanceEvaluation extends Configured implements Tool { this.presplitRegions = Integer.parseInt(cmd.substring(presplit.length())); continue; } - + + final String inMemory = "--inmemory="; + if (cmd.startsWith(inMemory)) { + this.inMemoryCF = Boolean.parseBoolean(cmd.substring(inMemory.length())); + continue; + } + Class cmdClass = determineCommandClass(cmd); if (cmdClass != null) { getArgs(i + 1, args); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java index c672884a156..e5ea6dbd528 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java @@ -86,6 +86,10 @@ public class LoadTestTool extends AbstractHBaseTool { public static final String OPT_ENCODE_IN_CACHE_ONLY_USAGE = "If this is specified, data blocks will only be encoded in block " + "cache but not on disk"; + + public static final String OPT_INMEMORY = "in_memory"; + public static final String OPT_USAGE_IN_MEMORY = "Tries to keep the HFiles of the CF " + + "inmemory as far as possible. Not guaranteed that reads are always served from inmemory"; private static final String OPT_KEY_WINDOW = "key_window"; private static final String OPT_WRITE = "write"; @@ -116,7 +120,7 @@ public class LoadTestTool extends AbstractHBaseTool { private boolean encodeInCacheOnly; private Compression.Algorithm compressAlgo; private BloomType bloomType; - + private boolean inMemoryCF; // Writer options private int numWriterThreads = DEFAULT_NUM_THREADS; private int minColsPerKey, maxColsPerKey; @@ -177,6 +181,9 @@ public class LoadTestTool extends AbstractHBaseTool { columnDesc.setDataBlockEncoding(dataBlockEncodingAlgo); columnDesc.setEncodeOnDisk(!encodeInCacheOnly); } + if (inMemoryCF) { + columnDesc.setInMemory(inMemoryCF); + } if (isNewCf) { admin.addColumn(tableName, columnDesc); } else { @@ -208,6 +215,7 @@ public class LoadTestTool extends AbstractHBaseTool { addOptNoArg(OPT_MULTIPUT, "Whether to use multi-puts as opposed to " + "separate puts for every column in a row"); addOptNoArg(OPT_ENCODE_IN_CACHE_ONLY, OPT_ENCODE_IN_CACHE_ONLY_USAGE); + addOptNoArg(OPT_INMEMORY, OPT_USAGE_IN_MEMORY); addOptWithArg(OPT_NUM_KEYS, "The number of keys to read/write"); addOptWithArg(OPT_START_KEY, "The first key to read/write " + @@ -318,6 +326,9 @@ public class LoadTestTool extends AbstractHBaseTool { String bloomStr = cmd.getOptionValue(OPT_BLOOM); bloomType = bloomStr == null ? null : BloomType.valueOf(bloomStr); + + inMemoryCF = cmd.hasOption(OPT_INMEMORY); + } public void initTestTable() throws IOException {