HBASE-8928: Make ChaosMonkey & LoadTest tools extensible (Gautam Soni)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1504609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8a21171f31
commit
0632023c14
|
@ -124,11 +124,11 @@ public class ChaosMonkey extends AbstractHBaseTool implements Stoppable {
|
||||||
this.util = util;
|
this.util = util;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntegrationTestingUtility getHaseIntegrationTestingUtility() {
|
public IntegrationTestingUtility getHaseIntegrationTestingUtility() {
|
||||||
return util;
|
return util;
|
||||||
}
|
}
|
||||||
|
|
||||||
HBaseCluster getHBaseCluster() {
|
public HBaseCluster getHBaseCluster() {
|
||||||
return util.getHBaseClusterInterface();
|
return util.getHBaseClusterInterface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -727,8 +727,8 @@ public class ChaosMonkey extends AbstractHBaseTool implements Stoppable {
|
||||||
/**
|
/**
|
||||||
* A context for a Policy
|
* A context for a Policy
|
||||||
*/
|
*/
|
||||||
private static class PolicyContext extends ActionContext {
|
public static class PolicyContext extends ActionContext {
|
||||||
PolicyContext(IntegrationTestingUtility util) {
|
public PolicyContext(IntegrationTestingUtility util) {
|
||||||
super(util);
|
super(util);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -737,7 +737,8 @@ public class ChaosMonkey extends AbstractHBaseTool implements Stoppable {
|
||||||
* A policy to introduce chaos to the cluster
|
* A policy to introduce chaos to the cluster
|
||||||
*/
|
*/
|
||||||
public static abstract class Policy extends StoppableImplementation implements Runnable {
|
public static abstract class Policy extends StoppableImplementation implements Runnable {
|
||||||
PolicyContext context;
|
protected PolicyContext context;
|
||||||
|
|
||||||
public void init(PolicyContext context) throws Exception {
|
public void init(PolicyContext context) throws Exception {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,33 +43,33 @@ public class LoadTestTool extends AbstractHBaseTool {
|
||||||
private static final Log LOG = LogFactory.getLog(LoadTestTool.class);
|
private static final Log LOG = LogFactory.getLog(LoadTestTool.class);
|
||||||
|
|
||||||
/** Table name for the test */
|
/** Table name for the test */
|
||||||
private byte[] tableName;
|
protected byte[] tableName;
|
||||||
|
|
||||||
/** Table name to use of not overridden on the command line */
|
/** Table name to use of not overridden on the command line */
|
||||||
private static final String DEFAULT_TABLE_NAME = "cluster_test";
|
protected static final String DEFAULT_TABLE_NAME = "cluster_test";
|
||||||
|
|
||||||
/** Column family used by the test */
|
/** Column family used by the test */
|
||||||
static byte[] COLUMN_FAMILY = Bytes.toBytes("test_cf");
|
protected static byte[] COLUMN_FAMILY = Bytes.toBytes("test_cf");
|
||||||
|
|
||||||
/** Column families used by the test */
|
/** Column families used by the test */
|
||||||
static final byte[][] COLUMN_FAMILIES = { COLUMN_FAMILY };
|
protected static final byte[][] COLUMN_FAMILIES = { COLUMN_FAMILY };
|
||||||
|
|
||||||
/** The number of reader/writer threads if not specified */
|
/** The number of reader/writer threads if not specified */
|
||||||
private static final int DEFAULT_NUM_THREADS = 20;
|
protected static final int DEFAULT_NUM_THREADS = 20;
|
||||||
|
|
||||||
/** Usage string for the load option */
|
/** Usage string for the load option */
|
||||||
private static final String OPT_USAGE_LOAD =
|
protected static final String OPT_USAGE_LOAD =
|
||||||
"<avg_cols_per_key>:<avg_data_size>" +
|
"<avg_cols_per_key>:<avg_data_size>" +
|
||||||
"[:<#threads=" + DEFAULT_NUM_THREADS + ">]";
|
"[:<#threads=" + DEFAULT_NUM_THREADS + ">]";
|
||||||
|
|
||||||
/** Usa\ge string for the read option */
|
/** Usa\ge string for the read option */
|
||||||
private static final String OPT_USAGE_READ =
|
protected static final String OPT_USAGE_READ =
|
||||||
"<verify_percent>[:<#threads=" + DEFAULT_NUM_THREADS + ">]";
|
"<verify_percent>[:<#threads=" + DEFAULT_NUM_THREADS + ">]";
|
||||||
|
|
||||||
private static final String OPT_USAGE_BLOOM = "Bloom filter type, one of " +
|
protected static final String OPT_USAGE_BLOOM = "Bloom filter type, one of " +
|
||||||
Arrays.toString(BloomType.values());
|
Arrays.toString(BloomType.values());
|
||||||
|
|
||||||
private static final String OPT_USAGE_COMPRESSION = "Compression type, " +
|
protected static final String OPT_USAGE_COMPRESSION = "Compression type, " +
|
||||||
"one of " + Arrays.toString(Compression.Algorithm.values());
|
"one of " + Arrays.toString(Compression.Algorithm.values());
|
||||||
|
|
||||||
public static final String OPT_DATA_BLOCK_ENCODING_USAGE =
|
public static final String OPT_DATA_BLOCK_ENCODING_USAGE =
|
||||||
|
@ -91,54 +91,54 @@ public class LoadTestTool extends AbstractHBaseTool {
|
||||||
public static final String OPT_USAGE_IN_MEMORY = "Tries to keep the HFiles of the CF " +
|
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";
|
"inmemory as far as possible. Not guaranteed that reads are always served from inmemory";
|
||||||
|
|
||||||
private static final String OPT_KEY_WINDOW = "key_window";
|
protected static final String OPT_KEY_WINDOW = "key_window";
|
||||||
private static final String OPT_WRITE = "write";
|
protected static final String OPT_WRITE = "write";
|
||||||
private static final String OPT_MAX_READ_ERRORS = "max_read_errors";
|
protected static final String OPT_MAX_READ_ERRORS = "max_read_errors";
|
||||||
private static final String OPT_MULTIPUT = "multiput";
|
protected static final String OPT_MULTIPUT = "multiput";
|
||||||
private static final String OPT_NUM_KEYS = "num_keys";
|
protected static final String OPT_NUM_KEYS = "num_keys";
|
||||||
private static final String OPT_READ = "read";
|
protected static final String OPT_READ = "read";
|
||||||
private static final String OPT_START_KEY = "start_key";
|
protected static final String OPT_START_KEY = "start_key";
|
||||||
private static final String OPT_TABLE_NAME = "tn";
|
protected static final String OPT_TABLE_NAME = "tn";
|
||||||
private static final String OPT_ZK_QUORUM = "zk";
|
protected static final String OPT_ZK_QUORUM = "zk";
|
||||||
private static final String OPT_SKIP_INIT = "skip_init";
|
protected static final String OPT_SKIP_INIT = "skip_init";
|
||||||
private static final String OPT_INIT_ONLY = "init_only";
|
protected static final String OPT_INIT_ONLY = "init_only";
|
||||||
|
|
||||||
private static final long DEFAULT_START_KEY = 0;
|
protected static final long DEFAULT_START_KEY = 0;
|
||||||
|
|
||||||
/** This will be removed as we factor out the dependency on command line */
|
/** This will be removed as we factor out the dependency on command line */
|
||||||
private CommandLine cmd;
|
protected CommandLine cmd;
|
||||||
|
|
||||||
private MultiThreadedWriter writerThreads = null;
|
protected MultiThreadedWriter writerThreads = null;
|
||||||
private MultiThreadedReader readerThreads = null;
|
protected MultiThreadedReader readerThreads = null;
|
||||||
|
|
||||||
private long startKey, endKey;
|
protected long startKey, endKey;
|
||||||
|
|
||||||
private boolean isWrite, isRead;
|
protected boolean isWrite, isRead;
|
||||||
|
|
||||||
// Column family options
|
// Column family options
|
||||||
private DataBlockEncoding dataBlockEncodingAlgo;
|
protected DataBlockEncoding dataBlockEncodingAlgo;
|
||||||
private boolean encodeInCacheOnly;
|
protected boolean encodeInCacheOnly;
|
||||||
private Compression.Algorithm compressAlgo;
|
protected Compression.Algorithm compressAlgo;
|
||||||
private BloomType bloomType;
|
protected BloomType bloomType;
|
||||||
private boolean inMemoryCF;
|
private boolean inMemoryCF;
|
||||||
// Writer options
|
// Writer options
|
||||||
private int numWriterThreads = DEFAULT_NUM_THREADS;
|
protected int numWriterThreads = DEFAULT_NUM_THREADS;
|
||||||
private int minColsPerKey, maxColsPerKey;
|
protected int minColsPerKey, maxColsPerKey;
|
||||||
private int minColDataSize, maxColDataSize;
|
protected int minColDataSize, maxColDataSize;
|
||||||
private boolean isMultiPut;
|
protected boolean isMultiPut;
|
||||||
|
|
||||||
// Reader options
|
// Reader options
|
||||||
private int numReaderThreads = DEFAULT_NUM_THREADS;
|
protected int numReaderThreads = DEFAULT_NUM_THREADS;
|
||||||
private int keyWindow = MultiThreadedReader.DEFAULT_KEY_WINDOW;
|
protected int keyWindow = MultiThreadedReader.DEFAULT_KEY_WINDOW;
|
||||||
private int maxReadErrors = MultiThreadedReader.DEFAULT_MAX_ERRORS;
|
protected int maxReadErrors = MultiThreadedReader.DEFAULT_MAX_ERRORS;
|
||||||
private int verifyPercent;
|
protected int verifyPercent;
|
||||||
|
|
||||||
// TODO: refactor LoadTestToolImpl somewhere to make the usage from tests less bad,
|
// TODO: refactor LoadTestToolImpl somewhere to make the usage from tests less bad,
|
||||||
// console tool itself should only be used from console.
|
// console tool itself should only be used from console.
|
||||||
private boolean isSkipInit = false;
|
protected boolean isSkipInit = false;
|
||||||
private boolean isInitOnly = false;
|
protected boolean isInitOnly = false;
|
||||||
|
|
||||||
private String[] splitColonSeparated(String option,
|
protected String[] splitColonSeparated(String option,
|
||||||
int minNumCols, int maxNumCols) {
|
int minNumCols, int maxNumCols) {
|
||||||
String optVal = cmd.getOptionValue(option);
|
String optVal = cmd.getOptionValue(option);
|
||||||
String[] cols = optVal.split(":");
|
String[] cols = optVal.split(":");
|
||||||
|
@ -151,7 +151,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
||||||
return cols;
|
return cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getNumThreads(String numThreadsStr) {
|
protected int getNumThreads(String numThreadsStr) {
|
||||||
return parseInt(numThreadsStr, 1, Short.MAX_VALUE);
|
return parseInt(numThreadsStr, 1, Short.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ public class LoadTestTool extends AbstractHBaseTool {
|
||||||
* Apply column family options such as Bloom filters, compression, and data
|
* Apply column family options such as Bloom filters, compression, and data
|
||||||
* block encoding.
|
* block encoding.
|
||||||
*/
|
*/
|
||||||
private void applyColumnFamilyOptions(byte[] tableName,
|
protected void applyColumnFamilyOptions(byte[] tableName,
|
||||||
byte[][] columnFamilies) throws IOException {
|
byte[][] columnFamilies) throws IOException {
|
||||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||||
HTableDescriptor tableDesc = admin.getTableDescriptor(tableName);
|
HTableDescriptor tableDesc = admin.getTableDescriptor(tableName);
|
||||||
|
|
Loading…
Reference in New Issue