@InterfaceAudience.Public @InterfaceStability.Evolving public class HBaseTestingUtility extends HBaseCommonTestingUtility
MiniHBaseCluster, or a deployed cluster of type DistributedHBaseCluster.
 Not all methods work with the real cluster.
 Depends on log4j being on classpath and
 hbase-site.xml for logging and test-run configuration.  It does not set
 logging levels nor make changes to configuration parameters.
 To preserve test data directories, pass the system property "hbase.testing.preserve.testdir" setting it to true.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
HBaseTestingUtility.SeenRowTracker
A tracker for tracking and validating table rows
 generated with  
HBaseTestingUtility#loadTable(HTable, byte[]) | 
| Modifier and Type | Field and Description | 
|---|---|
static Collection<Object[]> | 
BLOOM_AND_COMPRESSION_COMBINATIONS  | 
static List<Object[]> | 
BOOLEAN_PARAMETERIZED
This is for unit tests parameterized with a two booleans. 
 | 
static byte[][] | 
COLUMNS  | 
static Compression.Algorithm[] | 
COMPRESSION_ALGORITHMS
Compression algorithms to use in testing 
 | 
static List<Object[]> | 
COMPRESSION_ALGORITHMS_PARAMETERIZED
Compression algorithms to use in parameterized JUnit 4 tests 
 | 
static int | 
DEFAULT_REGIONS_PER_SERVER
The default number of regions per regionserver when creating a pre-split
 table. 
 | 
static byte[] | 
fam1  | 
static byte[] | 
fam2  | 
static byte[] | 
fam3  | 
static char | 
FIRST_CHAR  | 
static byte[][] | 
KEYS  | 
static byte[][] | 
KEYS_FOR_HBA_CREATE_TABLE  | 
static char | 
LAST_CHAR  | 
static List<Object[]> | 
MEMSTORETS_TAGS_PARAMETRIZED
This is for unit tests parameterized with a single boolean. 
 | 
static String | 
REGIONS_PER_SERVER_KEY  | 
static byte[][] | 
ROWS
All the row values for the data loaded by  
#loadTable(HTable, byte[]) | 
static String | 
START_KEY  | 
static byte[] | 
START_KEY_BYTES  | 
BASE_TEST_DIRECTORY_KEY, conf, DEFAULT_BASE_TEST_DIRECTORY, LOG| Constructor and Description | 
|---|
HBaseTestingUtility()  | 
HBaseTestingUtility(Configuration conf)  | 
| Modifier and Type | Method and Description | 
|---|---|
static void | 
assertKVListsEqual(String additionalMsg,
                  List<? extends Cell> expected,
                  List<? extends Cell> actual)  | 
void | 
assertRegionOnlyOnServer(HRegionInfo hri,
                        ServerName server,
                        long timeout)
Check to make sure the region is open on the specified
 region server, but not on any other one. 
 | 
void | 
assertRegionOnServer(HRegionInfo hri,
                    ServerName server,
                    long timeout)
Due to async racing issue, a region may not be in
  the online region list of a region server yet, after
  the assignment znode is deleted and the new assignment
  is recorded in master. 
 | 
static boolean | 
available(int port)
Checks to see if a specific port is available. 
 | 
String | 
checksumRows(Table table)
Return an md5 digest of the entire contents of a table. 
 | 
boolean | 
cleanupDataTestDirOnTestFS()
Cleans the test data directory on the test filesystem. 
 | 
boolean | 
cleanupDataTestDirOnTestFS(String subdirName)
Cleans a subdirectory under the test data directory on the test filesystem. 
 | 
boolean | 
cleanupTestDir()  | 
void | 
closeRegion(byte[] regionName)
Closes the named region. 
 | 
static void | 
closeRegion(Region r)
Close the Region  
r. | 
void | 
closeRegion(String regionName)
Closes the named region. 
 | 
static void | 
closeRegionAndWAL(HRegion r)
Close both the HRegion  
r and it's underlying WAL. | 
static void | 
closeRegionAndWAL(Region r)
Close both the region  
r and it's underlying WAL. | 
void | 
closeRegionByRow(byte[] row,
                RegionLocator table)
Closes the region containing the given row. 
 | 
void | 
closeRegionByRow(String row,
                RegionLocator table)
Closes the region containing the given row. 
 | 
void | 
compact(boolean major)
Compact all regions in the mini hbase cluster 
 | 
void | 
compact(TableName tableName,
       boolean major)
Compact all of a table's reagion in the mini hbase cluster 
 | 
int | 
countRows(Table table)
Return the number of rows in the given table. 
 | 
int | 
countRows(Table table,
         byte[]... families)  | 
int | 
countRows(TableName tableName)
Return the number of rows in the given table. 
 | 
int | 
countRows(Table table,
         Scan scan)  | 
static ZooKeeperWatcher | 
createAndForceNodeToOpenedState(HBaseTestingUtility TEST_UTIL,
                               HRegion region,
                               ServerName serverName)
Creates a znode with OPENED state. 
 | 
static ZooKeeperWatcher | 
createAndForceNodeToOpenedState(HBaseTestingUtility TEST_UTIL,
                               Region region,
                               ServerName serverName)
Creates a znode with OPENED state. 
 | 
HRegion | 
createHRegion(HRegionInfo info,
             Path rootDir,
             Configuration conf,
             HTableDescriptor htd)
Create an HRegion. 
 | 
HRegion | 
createLocalHRegion(byte[] tableName,
                  byte[] startKey,
                  byte[] stopKey,
                  String callingMethod,
                  Configuration conf,
                  boolean isReadOnly,
                  Durability durability,
                  WAL wal,
                  byte[]... families)  | 
HRegion | 
createLocalHRegion(HRegionInfo info,
                  HTableDescriptor desc)
Create an HRegion that writes to the local tmp dirs 
 | 
HRegion | 
createLocalHRegion(HRegionInfo info,
                  HTableDescriptor desc,
                  WAL wal)
Create an HRegion that writes to the local tmp dirs with specified wal 
 | 
HRegion | 
createLocalHRegion(HTableDescriptor desc,
                  byte[] startKey,
                  byte[] endKey)
Create an HRegion that writes to the local tmp dirs 
 | 
static HBaseTestingUtility | 
createLocalHTU()
Create an HBaseTestingUtility where all tmp files are written to the local test data dir. 
 | 
static HBaseTestingUtility | 
createLocalHTU(Configuration c)
Create an HBaseTestingUtility where all tmp files are written to the local test data dir. 
 | 
RegionServerServices | 
createMockRegionServerService()
Create a stubbed out RegionServerService, mainly for getting FS. 
 | 
RegionServerServices | 
createMockRegionServerService(RpcServerInterface rpc)
Create a stubbed out RegionServerService, mainly for getting FS. 
 | 
RegionServerServices | 
createMockRegionServerService(ServerName name)
Create a stubbed out RegionServerService, mainly for getting FS. 
 | 
List<HRegionInfo> | 
createMultiRegionsInMeta(Configuration conf,
                        HTableDescriptor htd,
                        byte[][] startKeys)
Create rows in hbase:meta for regions of the specified table with the specified
 start keys. 
 | 
HTable | 
createMultiRegionTable(TableName tableName,
                      byte[] family)
Create a table with multiple regions. 
 | 
HTable | 
createMultiRegionTable(TableName tableName,
                      byte[][] families)
Create a table with multiple regions. 
 | 
HTable | 
createMultiRegionTable(TableName tableName,
                      byte[][] families,
                      int numVersions)
Create a table with multiple regions. 
 | 
HTable | 
createMultiRegionTable(TableName tableName,
                      byte[] family,
                      int numRegions)
Create a table with multiple regions. 
 | 
static int | 
createPreSplitLoadTestTable(Configuration conf,
                           HTableDescriptor desc,
                           HColumnDescriptor hcd)
Creates a pre-split table for load testing. 
 | 
static int | 
createPreSplitLoadTestTable(Configuration conf,
                           HTableDescriptor desc,
                           HColumnDescriptor[] hcds,
                           int numRegionsPerServer)
Creates a pre-split table for load testing. 
 | 
static int | 
createPreSplitLoadTestTable(Configuration conf,
                           HTableDescriptor desc,
                           HColumnDescriptor hcd,
                           int numRegionsPerServer)
Creates a pre-split table for load testing. 
 | 
static int | 
createPreSplitLoadTestTable(Configuration conf,
                           TableName tableName,
                           byte[][] columnFamilies,
                           Compression.Algorithm compression,
                           DataBlockEncoding dataBlockEncoding,
                           int numRegionsPerServer,
                           int regionReplication,
                           Durability durability)
Creates a pre-split table for load testing. 
 | 
static int | 
createPreSplitLoadTestTable(Configuration conf,
                           TableName tableName,
                           byte[] columnFamily,
                           Compression.Algorithm compression,
                           DataBlockEncoding dataBlockEncoding)
Creates a pre-split table for load testing. 
 | 
static int | 
createPreSplitLoadTestTable(Configuration conf,
                           TableName tableName,
                           byte[] columnFamily,
                           Compression.Algorithm compression,
                           DataBlockEncoding dataBlockEncoding,
                           int numRegionsPerServer,
                           int regionReplication,
                           Durability durability)
Creates a pre-split table for load testing. 
 | 
HTable | 
createRandomTable(String tableName,
                 Collection<String> families,
                 int maxVersions,
                 int numColsPerRow,
                 int numFlushes,
                 int numRegions,
                 int numRowsPerFlush)
Creates a random table with the given parameters 
 | 
static HRegion | 
createRegionAndWAL(HRegionInfo info,
                  Path rootDir,
                  Path walRootDir,
                  Configuration conf,
                  HTableDescriptor htd)
Create a region with it's own WAL. 
 | 
static HRegion | 
createRegionAndWAL(HRegionInfo info,
                  Path rootDir,
                  Path walRootDir,
                  Configuration conf,
                  HTableDescriptor htd,
                  boolean initialize)
Create a region with it's own WAL. 
 | 
Path | 
createRootDir()
Same as  
createRootDir(boolean create)
 except that create flag is false. | 
Path | 
createRootDir(boolean create)
Creates an hbase rootdir in user home directory. 
 | 
HTable | 
createTable(byte[] tableName,
           byte[] family)
Create a table. 
 | 
HTable | 
createTable(byte[] tableName,
           byte[][] families)
Create a table. 
 | 
HTable | 
createTable(byte[] tableName,
           byte[][] families,
           Configuration c)
Create a table. 
 | 
HTable | 
createTable(byte[] tableName,
           byte[][] families,
           Configuration c,
           int numVersions)
Create a table. 
 | 
HTable | 
createTable(byte[] tableName,
           byte[][] families,
           int numVersions,
           byte[] startKey,
           byte[] endKey,
           int numRegions)  | 
HTable | 
createTable(byte[] tableName,
           byte[] family,
           byte[][] splitRows)
Create a table. 
 | 
HTable | 
createTable(byte[] tableName,
           byte[] family,
           int numVersions)
Create a table. 
 | 
HTable | 
createTable(HTableDescriptor htd,
           byte[][] splitRows)
Create a table. 
 | 
HTable | 
createTable(HTableDescriptor htd,
           byte[][] families,
           byte[][] splitKeys,
           Configuration c)
Create a table. 
 | 
HTable | 
createTable(HTableDescriptor htd,
           byte[][] families,
           Configuration c)
Create a table. 
 | 
HTable | 
createTable(String tableName,
           byte[][] families,
           int numVersions,
           byte[] startKey,
           byte[] endKey,
           int numRegions)  | 
HTable | 
createTable(TableName tableName,
           byte[] family)
Create a table. 
 | 
HTable | 
createTable(TableName tableName,
           byte[][] families)
Create a table. 
 | 
HTable | 
createTable(TableName tableName,
           byte[][] families,
           byte[][] splitKeys)
Create a table. 
 | 
HTable | 
createTable(TableName tableName,
           byte[][] families,
           byte[][] splitKeys,
           Configuration c)
Create a table. 
 | 
HTable | 
createTable(TableName tableName,
           byte[][] families,
           Configuration c)
Create a table. 
 | 
HTable | 
createTable(TableName tableName,
           byte[][] families,
           Configuration c,
           int numVersions)
Create a table. 
 | 
HTable | 
createTable(TableName tableName,
           byte[][] families,
           int numVersions,
           byte[][] splitKeys)
Create a table. 
 | 
HTable | 
createTable(TableName tableName,
           byte[][] families,
           int numVersions,
           byte[] startKey,
           byte[] endKey,
           int numRegions)  | 
HTable | 
createTable(TableName tableName,
           byte[] family,
           byte[][] splitRows)
Create a table. 
 | 
HTable | 
createTable(TableName tableName,
           byte[] family,
           int numVersions)
Create a table. 
 | 
Table | 
createTable(TableName tableName,
           String family)
Create a table. 
 | 
Table | 
createTable(TableName tableName,
           String[] families)
Create a table. 
 | 
HTableDescriptor | 
createTableDescriptor(String name)
Create a table of name  
name with COLUMNS for
 families. | 
HTableDescriptor | 
createTableDescriptor(String name,
                     int minVersions,
                     int versions,
                     int ttl,
                     KeepDeletedCells keepDeleted)
Create a table of name  
name with COLUMNS for
 families. | 
HTableDescriptor | 
createTableDescriptor(TableName tableName,
                     byte[] family)  | 
HTableDescriptor | 
createTableDescriptor(TableName tableName,
                     byte[][] families,
                     int maxVersions)  | 
HRegion | 
createTestRegion(String tableName,
                HColumnDescriptor hcd)  | 
static WAL | 
createWal(Configuration conf,
         Path rootDir,
         Path walRootDir,
         HRegionInfo hri)
Create an unmanaged WAL. 
 | 
Path | 
createWALRootDir()
Creates a hbase walDir in the user's home directory. 
 | 
void | 
deleteNumericRows(HTable t,
                 byte[] f,
                 int startRow,
                 int endRow)  | 
void | 
deleteTable(byte[] tableName)
Drop an existing table 
 | 
void | 
deleteTable(String tableName)
Drop an existing table 
 | 
void | 
deleteTable(TableName tableName)
Drop an existing table 
 | 
HTable | 
deleteTableData(byte[] tableName)
Provide an existing table name to truncate. 
 | 
HTable | 
deleteTableData(TableName tableName)
Provide an existing table name to truncate. 
 | 
void | 
deleteTableIfAny(TableName tableName)
Drop an existing table 
 | 
void | 
enableDebug(Class<?> clazz)
Switches the logger for the given class to DEBUG level. 
 | 
boolean | 
ensureSomeNonStoppedRegionServersAvailable(int num)
Make sure that at least the specified number of region servers
 are running. 
 | 
boolean | 
ensureSomeRegionServersAvailable(int num)
Make sure that at least the specified number of region servers
 are running 
 | 
void | 
expireMasterSession()
Expire the Master's session 
 | 
void | 
expireRegionServerSession(int index)
Expire a region server's session 
 | 
void | 
expireSession(ZooKeeperWatcher nodeZK)  | 
void | 
expireSession(ZooKeeperWatcher nodeZK,
             boolean checkStatus)
Expire a ZooKeeper session as recommended in ZooKeeper documentation
 http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A4
 There are issues when doing this:
 [1] http://www.mail-archive.com/dev@zookeeper.apache.org/msg01942.html
 [2] https://issues.apache.org/jira/browse/ZOOKEEPER-1105 
 | 
void | 
expireSession(ZooKeeperWatcher nodeZK,
             Server server)
Deprecated.  
 | 
String | 
explainTableAvailability(TableName tableName)  | 
String | 
explainTableState(TableName tableName)  | 
void | 
flush()
Flushes all caches in the mini hbase cluster 
 | 
void | 
flush(TableName tableName)
Flushes all caches in the mini hbase cluster 
 | 
static List<HColumnDescriptor> | 
generateColumnDescriptors()
Create a set of column descriptors with the combination of compression,
 encoding, bloom codecs available. 
 | 
static List<HColumnDescriptor> | 
generateColumnDescriptors(String prefix)
Create a set of column descriptors with the combination of compression,
 encoding, bloom codecs available. 
 | 
static NavigableSet<String> | 
getAllOnlineRegions(MiniHBaseCluster cluster)  | 
String | 
getClusterKey()  | 
Configuration | 
getConfiguration()
Returns this classes's instance of  
Configuration. | 
Connection | 
getConnection()
Get a Connection to the cluster. 
 | 
Path | 
getDataTestDirOnTestFS()
Returns a Path in the test filesystem, obtained from  
getTestFileSystem()
 to write temporary test data. | 
Path | 
getDataTestDirOnTestFS(String subdirName)
Returns a Path in the test filesystem, obtained from  
getTestFileSystem()
 to write temporary test data. | 
Path | 
getDefaultRootDirPath()
Same as { 
getDefaultRootDirPath(boolean create)
 except that create flag is false. | 
Path | 
getDefaultRootDirPath(boolean create)
Returns the path to the default root dir the minicluster uses. 
 | 
MiniDFSCluster | 
getDFSCluster()  | 
static User | 
getDifferentUser(Configuration c,
                String differentiatingSuffix)
This method clones the passed  
c configuration setting a new
 user into the clone. | 
static List<Cell> | 
getFromStoreFile(HStore store,
                byte[] row,
                NavigableSet<byte[]> columns)
Do a small get/scan against one store. 
 | 
static List<Cell> | 
getFromStoreFile(HStore store,
                Get get)
Do a small get/scan against one store. 
 | 
HBaseAdmin | 
getHBaseAdmin()
Returns a Admin instance. 
 | 
MiniHBaseCluster | 
getHBaseCluster()
Get the Mini HBase cluster. 
 | 
HBaseCluster | 
getHBaseClusterInterface()
Returns the HBaseCluster instance. 
 | 
static int | 
getMetaRSPort(Configuration conf)  | 
HTableDescriptor | 
getMetaTableDescriptor()  | 
List<byte[]> | 
getMetaTableRows()
Returns all rows from the hbase:meta table. 
 | 
List<byte[]> | 
getMetaTableRows(TableName tableName)
Returns all rows from the hbase:meta table for a given user table 
 | 
MiniHBaseCluster | 
getMiniHBaseCluster()  | 
byte[][] | 
getRegionSplitStartKeys(byte[] startKey,
                       byte[] endKey,
                       int numRegions)
Create region split keys between startkey and endKey 
 | 
HRegionServer | 
getRSForFirstRegionInTable(TableName tableName)
Tool to get the reference to the region server object that holds the
 region of the specified user table. 
 | 
HRegion | 
getSplittableRegion(TableName tableName,
                   int maxAttempts)  | 
static Compression.Algorithm[] | 
getSupportedCompressionAlgorithms()
Get supported compression algorithms. 
 | 
FileSystem | 
getTestFileSystem()  | 
MiniZooKeeperCluster | 
getZkCluster()  | 
ZooKeeperWatcher | 
getZooKeeperWatcher()
Returns a ZooKeeperWatcher instance. 
 | 
static ZooKeeperWatcher | 
getZooKeeperWatcher(HBaseTestingUtility TEST_UTIL)
Gets a ZooKeeperWatcher. 
 | 
boolean | 
isReadShortCircuitOn()
Get the HBase setting for dfs.client.read.shortcircuit from the conf or a system property. 
 | 
void | 
loadNumericRows(Table t,
               byte[] f,
               int startRow,
               int endRow)  | 
int | 
loadRegion(HRegion r,
          byte[] f)  | 
int | 
loadRegion(HRegion r,
          byte[] f,
          boolean flush)
Load region with rows from 'aaa' to 'zzz'. 
 | 
int | 
loadRegion(Region r,
          byte[] f)  | 
int | 
loadTable(Table t,
         byte[] f)
Load table with rows from 'aaa' to 'zzz'. 
 | 
int | 
loadTable(Table t,
         byte[][] f)
Load table of multiple column families with rows from 'aaa' to 'zzz'. 
 | 
int | 
loadTable(Table t,
         byte[][] f,
         byte[] value)
Load table of multiple column families with rows from 'aaa' to 'zzz'. 
 | 
int | 
loadTable(Table t,
         byte[][] f,
         byte[] value,
         boolean writeToWAL)
Load table of multiple column families with rows from 'aaa' to 'zzz'. 
 | 
int | 
loadTable(Table t,
         byte[] f,
         boolean writeToWAL)
Load table with rows from 'aaa' to 'zzz'. 
 | 
static void | 
modifyTableSync(Admin admin,
               HTableDescriptor desc)
Modify a table, synchronous. 
 | 
Waiter.ExplainingPredicate<IOException> | 
predicateNoRegionsInTransition()
Returns a  
Waiter.Predicate for checking that there are no regions in transition in master | 
Waiter.Predicate<IOException> | 
predicateTableAvailable(TableName tableName)
Returns a  
Waiter.Predicate for checking that table is enabled | 
Waiter.Predicate<IOException> | 
predicateTableDisabled(TableName tableName)
Returns a  
Waiter.Predicate for checking that table is enabled | 
Waiter.Predicate<IOException> | 
predicateTableEnabled(TableName tableName)
Returns a  
Waiter.Predicate for checking that table is enabled | 
static int | 
randomFreePort()
Returns a random free port and marks that port as taken. 
 | 
static String | 
randomMultiCastAddress()  | 
static int | 
randomPort()
Returns a random port. 
 | 
void | 
restartHBaseCluster(int servers)
Starts the hbase cluster up again after shutting it down previously in a
 test. 
 | 
static <T> String | 
safeGetAsStr(List<T> lst,
            int i)  | 
void | 
setDFSCluster(MiniDFSCluster cluster)  | 
void | 
setDFSCluster(MiniDFSCluster cluster,
             boolean requireDown)
Set the MiniDFSCluster 
 | 
void | 
setFileSystemURI(String fsURI)  | 
void | 
setHBaseCluster(HBaseCluster hbaseCluster)  | 
static void | 
setMaxRecoveryErrorCount(OutputStream stream,
                        int max)
Set maxRecoveryErrorCount in DFSClient. 
 | 
static void | 
setReplicas(Admin admin,
           TableName table,
           int replicaCount)
Set the number of Region replicas. 
 | 
protected Path | 
setupDataTestDir()
Home our data in a dir under  
HBaseCommonTestingUtility.DEFAULT_BASE_TEST_DIRECTORY. | 
void | 
setZkCluster(MiniZooKeeperCluster zkCluster)  | 
void | 
shutdownMiniCluster()
Stops mini hbase, zk, and hdfs clusters. 
 | 
void | 
shutdownMiniDFSCluster()
Shuts down instance created by call to  
startMiniDFSCluster(int)
 or does nothing. | 
void | 
shutdownMiniHBaseCluster()
Shutdown HBase mini cluster. 
 | 
void | 
shutdownMiniMapReduceCluster()
Stops the previously started  
MiniMRCluster. | 
void | 
shutdownMiniZKCluster()
Shuts down zk cluster created by call to  
startMiniZKCluster(File)
 or does nothing. | 
MiniHBaseCluster | 
startMiniCluster()
Start up a minicluster of hbase, dfs, and zookeeper. 
 | 
MiniHBaseCluster | 
startMiniCluster(boolean withWALDir)
Start up a minicluster of hbase, dfs, and zookeeper where WAL's walDir is created separately. 
 | 
MiniHBaseCluster | 
startMiniCluster(int numSlaves)
Start up a minicluster of hbase, optionally dfs, and zookeeper. 
 | 
MiniHBaseCluster | 
startMiniCluster(int numSlaves,
                boolean create)
Start up a minicluster of hbase, dfs, and zookeeper. 
 | 
MiniHBaseCluster | 
startMiniCluster(int numSlaves,
                boolean create,
                boolean withWALDir)  | 
MiniHBaseCluster | 
startMiniCluster(int numMasters,
                int numSlaves)
start minicluster 
 | 
MiniHBaseCluster | 
startMiniCluster(int numMasters,
                int numSlaves,
                boolean create)
Start minicluster. 
 | 
MiniHBaseCluster | 
startMiniCluster(int numMasters,
                int numSlaves,
                int numDataNodes)
Same as  
startMiniCluster(int, int), but with custom number of datanodes. | 
MiniHBaseCluster | 
startMiniCluster(int numMasters,
                int numSlaves,
                int numDataNodes,
                String[] dataNodeHosts,
                Class<? extends HMaster> masterClass,
                Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass)  | 
MiniHBaseCluster | 
startMiniCluster(int numMasters,
                int numSlaves,
                int numDataNodes,
                String[] dataNodeHosts,
                Class<? extends HMaster> masterClass,
                Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass,
                boolean create,
                boolean withWALDir)
Same as  
startMiniCluster(int, int, String[], Class, Class), but with custom
 number of datanodes. | 
MiniHBaseCluster | 
startMiniCluster(int numMasters,
                int numSlaves,
                String[] dataNodeHosts)
Start up a minicluster of hbase, optionally dfs, and zookeeper. 
 | 
MiniHBaseCluster | 
startMiniCluster(int numMasters,
                int numSlaves,
                String[] dataNodeHosts,
                boolean create)  | 
MiniHBaseCluster | 
startMiniCluster(int numMasters,
                int numSlaves,
                String[] dataNodeHosts,
                Class<? extends HMaster> masterClass,
                Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass)
Start up a minicluster of hbase, optionally dfs, and zookeeper. 
 | 
MiniDFSCluster | 
startMiniDFSCluster(int servers)
Start a minidfscluster. 
 | 
MiniDFSCluster | 
startMiniDFSCluster(int servers,
                   String[] hosts)
Start a minidfscluster. 
 | 
MiniDFSCluster | 
startMiniDFSCluster(int servers,
                   String[] racks,
                   String[] hosts)  | 
MiniDFSCluster | 
startMiniDFSCluster(String[] hosts)
Start a minidfscluster. 
 | 
MiniDFSCluster | 
startMiniDFSClusterForTestWAL(int namenodePort)  | 
MiniHBaseCluster | 
startMiniHBaseCluster(int numMasters,
                     int numSlaves)  | 
MiniHBaseCluster | 
startMiniHBaseCluster(int numMasters,
                     int numSlaves,
                     Class<? extends HMaster> masterClass,
                     Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass,
                     boolean create,
                     boolean withWALDir)
Starts up mini hbase cluster. 
 | 
MiniMRCluster | 
startMiniMapReduceCluster()
Starts a  
MiniMRCluster with a default number of
 TaskTracker's. | 
MiniZooKeeperCluster | 
startMiniZKCluster()
Call this if you only want a zk cluster. 
 | 
MiniZooKeeperCluster | 
startMiniZKCluster(int zooKeeperServerNum,
                  int... clientPortList)
Call this if you only want a zk cluster. 
 | 
HTable | 
truncateTable(byte[] tableName)
Truncate a table using the admin command. 
 | 
HTable | 
truncateTable(byte[] tableName,
             boolean preserveRegions)
Truncate a table using the admin command. 
 | 
HTable | 
truncateTable(TableName tableName)
Truncate a table using the admin command. 
 | 
HTable | 
truncateTable(TableName tableName,
             boolean preserveRegions)
Truncate a table using the admin command. 
 | 
void | 
verifyNumericRows(HRegion region,
                 byte[] f,
                 int startRow,
                 int endRow)  | 
void | 
verifyNumericRows(HRegion region,
                 byte[] f,
                 int startRow,
                 int endRow,
                 boolean present)  | 
void | 
verifyNumericRows(Region region,
                 byte[] f,
                 int startRow,
                 int endRow)  | 
void | 
verifyNumericRows(Region region,
                 byte[] f,
                 int startRow,
                 int endRow,
                 boolean present)  | 
void | 
verifyNumericRows(Table table,
                 byte[] f,
                 int startRow,
                 int endRow,
                 int replicaId)  | 
<E extends Exception> | 
waitFor(long timeout,
       long interval,
       boolean failIfTimeout,
       Waiter.Predicate<E> predicate)
Wrapper method for  
Waiter.waitFor(Configuration, long, long, boolean, Predicate). | 
<E extends Exception> | 
waitFor(long timeout,
       long interval,
       Waiter.Predicate<E> predicate)
Wrapper method for  
Waiter.waitFor(Configuration, long, long, Predicate). | 
<E extends Exception> | 
waitFor(long timeout,
       Waiter.Predicate<E> predicate)
Wrapper method for  
Waiter.waitFor(Configuration, long, Predicate). | 
static void | 
waitForHostPort(String host,
               int port)  | 
void | 
waitLabelAvailable(long timeoutMillis,
                  String... labels)
Wait until labels is ready in VisibilityLabelsCache. 
 | 
void | 
waitTableAvailable(Admin admin,
                  byte[] table,
                  long timeoutMillis)  | 
void | 
waitTableAvailable(byte[] table,
                  long timeoutMillis)
Wait until all regions in a table have been assigned 
 | 
void | 
waitTableAvailable(TableName table)
Wait until all regions in a table have been assigned. 
 | 
void | 
waitTableAvailable(TableName table,
                  long timeoutMillis)  | 
void | 
waitTableDisabled(Admin admin,
                 byte[] table)  | 
void | 
waitTableDisabled(Admin admin,
                 byte[] table,
                 long timeoutMillis)  | 
void | 
waitTableDisabled(byte[] table)
Waits for a table to be 'disabled'. 
 | 
void | 
waitTableDisabled(byte[] table,
                 long timeoutMillis)
Waits for a table to be 'disabled'. 
 | 
void | 
waitTableEnabled(byte[] table,
                long timeoutMillis)
Waits for a table to be 'enabled'. 
 | 
void | 
waitTableEnabled(TableName table)
Waits for a table to be 'enabled'. 
 | 
void | 
waitTableEnabled(TableName table,
                long timeoutMillis)  | 
void | 
waitUntilAllRegionsAssigned(TableName tableName)
Wait until all regions for a table in hbase:meta have a non-empty
 info:server, up to a configuable timeout value (default is 60 seconds)
 This means all regions have been deployed,
 master has been informed and updated hbase:meta with the regions deployed
 server. 
 | 
void | 
waitUntilAllRegionsAssigned(TableName tableName,
                           long timeout)
Wait until all regions for a table in hbase:meta have a non-empty
 info:server, or until timeout. 
 | 
void | 
waitUntilAllSystemRegionsAssigned()
Waith until all system table's regions get assigned 
 | 
void | 
waitUntilNoRegionsInTransition(long timeout)
Wait until no regions in transition. 
 | 
createSubDir, getDataTestDir, getDataTestDirpublic static final String REGIONS_PER_SERVER_KEY
public static final int DEFAULT_REGIONS_PER_SERVER
public static final List<Object[]> COMPRESSION_ALGORITHMS_PARAMETERIZED
public static final List<Object[]> BOOLEAN_PARAMETERIZED
public static final List<Object[]> MEMSTORETS_TAGS_PARAMETRIZED
public static final Compression.Algorithm[] COMPRESSION_ALGORITHMS
public static final Collection<Object[]> BLOOM_AND_COMPRESSION_COMBINATIONS
public static final byte[] fam1
public static final byte[] fam2
public static final byte[] fam3
public static final byte[][] COLUMNS
public static final char FIRST_CHAR
public static final char LAST_CHAR
public static final byte[] START_KEY_BYTES
public static final String START_KEY
public static final byte[][] ROWS
#loadTable(HTable, byte[])public static final byte[][] KEYS
public static final byte[][] KEYS_FOR_HBA_CREATE_TABLE
public HBaseTestingUtility()
public HBaseTestingUtility(Configuration conf)
public static boolean available(int port)
port - the port number to check for availabilitypublic static HBaseTestingUtility createLocalHTU()
public static HBaseTestingUtility createLocalHTU(Configuration c)
c - Configuration (will be modified)public static void closeRegion(Region r) throws IOException
r. For use in tests.IOExceptionpublic Configuration getConfiguration()
Configuration.  Be careful how
 you use the returned Configuration since HConnection instances
 can be shared.  The Map of HConnections is keyed by the Configuration.  If
 say, a Connection was being used against a cluster that had been shutdown,
 see shutdownMiniCluster(), then the Connection will no longer
 be wholesome.  Rather than use the return direct, its usually best to
 make a copy and use that.  Do
 Configuration c = new Configuration(INSTANCE.getConfiguration());getConfiguration in class HBaseCommonTestingUtilitypublic void setHBaseCluster(HBaseCluster hbaseCluster)
protected Path setupDataTestDir()
HBaseCommonTestingUtility.DEFAULT_BASE_TEST_DIRECTORY.
 Give it a random name so can have many concurrent tests running if
 we need to.  It needs to amend the TEST_DIRECTORY_KEY
 System property, as it's what minidfscluster bases
 it data dir on.  Moding a System property is not the way to do concurrent
 instances -- another instance could grab the temporary
 value unintentionally -- but not anything can do about it at moment;
 single instance only is how the minidfscluster works.
 We also create the underlying directory for
  hadoop.log.dir, mapreduce.cluster.local.dir and hadoop.tmp.dir, and set the values
  in the conf, and as a system property for hadoop.tmp.dirsetupDataTestDir in class HBaseCommonTestingUtilitypublic HTableDescriptor getMetaTableDescriptor()
public Path getDataTestDirOnTestFS()
                            throws IOException
getTestFileSystem()
 to write temporary test data. Call this method after setting up the mini dfs cluster
 if the test relies on it.IOExceptionpublic Path getDataTestDirOnTestFS(String subdirName) throws IOException
getTestFileSystem()
 to write temporary test data. Call this method after setting up the mini dfs cluster
 if the test relies on it.subdirName - name of the subdir to create under the base test dirIOExceptionpublic boolean cleanupDataTestDirOnTestFS()
                                   throws IOException
IOExceptionpublic boolean cleanupDataTestDirOnTestFS(String subdirName) throws IOException
IOExceptionpublic MiniDFSCluster startMiniDFSCluster(int servers)
                                   throws Exception
servers - How many DNs to start.Exception#shutdownMiniDFSCluster()}public MiniDFSCluster startMiniDFSCluster(String[] hosts) throws Exception
hosts - hostnames DNs to run on.Exception#shutdownMiniDFSCluster()}public MiniDFSCluster startMiniDFSCluster(int servers,
                                          String[] hosts)
                                   throws Exception
servers - How many DNs to start.hosts - hostnames DNs to run on.Exception#shutdownMiniDFSCluster()}public MiniDFSCluster startMiniDFSCluster(int servers,
                                          String[] racks,
                                          String[] hosts)
                                   throws Exception
Exceptionpublic MiniDFSCluster startMiniDFSClusterForTestWAL(int namenodePort)
                                             throws IOException
IOExceptionpublic boolean isReadShortCircuitOn()
public void shutdownMiniDFSCluster()
                            throws IOException
startMiniDFSCluster(int)
 or does nothing.IOExceptionpublic MiniZooKeeperCluster startMiniZKCluster() throws Exception
Exceptionif you want zk + dfs + hbase mini cluster., 
shutdownMiniZKCluster()public MiniZooKeeperCluster startMiniZKCluster(int zooKeeperServerNum, int... clientPortList) throws Exception
zooKeeperServerNum - Exceptionif you want zk + dfs + hbase mini cluster., 
shutdownMiniZKCluster()public void shutdownMiniZKCluster()
                           throws IOException
startMiniZKCluster(File)
 or does nothing.IOExceptionstartMiniZKCluster()public MiniHBaseCluster startMiniCluster() throws Exception
Exception#shutdownMiniDFSCluster()}public MiniHBaseCluster startMiniCluster(boolean withWALDir) throws Exception
Exception#shutdownMiniDFSCluster()}public MiniHBaseCluster startMiniCluster(int numSlaves, boolean create) throws Exception
create flag to create root or data directory path or not
 (will overwrite if dir already exists)Exception#shutdownMiniDFSCluster()}public MiniHBaseCluster startMiniCluster(int numSlaves) throws Exception
numSlaves - Number of slaves to start up.  We'll start this many
 datanodes and regionservers.  If numSlaves is > 1, then make sure
 hbase.regionserver.info.port is -1 (i.e. no ui per regionserver) otherwise
 bind errors.Exception#shutdownMiniCluster()}public MiniHBaseCluster startMiniCluster(int numSlaves, boolean create, boolean withWALDir) throws Exception
Exceptionpublic MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, boolean create) throws Exception
createException#shutdownMiniCluster()}public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves) throws Exception
Exception#shutdownMiniCluster()}public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, String[] dataNodeHosts, boolean create) throws Exception
Exceptionpublic MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, String[] dataNodeHosts) throws Exception
numMasters - Number of masters to start up.  We'll start this many
 hbase masters.  If numMasters > 1, you can find the active/primary master
 with MiniHBaseCluster.getMaster().numSlaves - Number of slaves to start up.  We'll start this many
 regionservers. If dataNodeHosts == null, this also indicates the number of
 datanodes to start. If dataNodeHosts != null, the number of datanodes is
 based on dataNodeHosts.length.
 If numSlaves is > 1, then make sure
 hbase.regionserver.info.port is -1 (i.e. no ui per regionserver) otherwise
 bind errors.dataNodeHosts - hostnames DNs to run on.
 This is useful if you want to run datanode on distinct hosts for things
 like HDFS block location verification.
 If you start MiniDFSCluster without host names,
 all instances of the datanodes will have the same host name.Exception#shutdownMiniCluster()}public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, int numDataNodes) throws Exception
startMiniCluster(int, int), but with custom number of datanodes.numDataNodes - Number of data nodes.Exceptionpublic MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, String[] dataNodeHosts, Class<? extends HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass) throws Exception
numMasters - Number of masters to start up.  We'll start this many
 hbase masters.  If numMasters > 1, you can find the active/primary master
 with MiniHBaseCluster.getMaster().numSlaves - Number of slaves to start up.  We'll start this many
 regionservers. If dataNodeHosts == null, this also indicates the number of
 datanodes to start. If dataNodeHosts != null, the number of datanodes is
 based on dataNodeHosts.length.
 If numSlaves is > 1, then make sure
 hbase.regionserver.info.port is -1 (i.e. no ui per regionserver) otherwise
 bind errors.dataNodeHosts - hostnames DNs to run on.
 This is useful if you want to run datanode on distinct hosts for things
 like HDFS block location verification.
 If you start MiniDFSCluster without host names,
 all instances of the datanodes will have the same host name.masterClass - The class to use as HMaster, or null for defaultregionserverClass - The class to use as HRegionServer, or null for
 defaultException#shutdownMiniCluster()}public MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, int numDataNodes, String[] dataNodeHosts, Class<? extends HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass) throws Exception
Exceptionpublic MiniHBaseCluster startMiniCluster(int numMasters, int numSlaves, int numDataNodes, String[] dataNodeHosts, Class<? extends HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass, boolean create, boolean withWALDir) throws Exception
startMiniCluster(int, int, String[], Class, Class), but with custom
 number of datanodes.numDataNodes - Number of data nodes.create - Set this flag to create a new
 root or data directory path or not (will overwrite if exists already).Exceptionpublic MiniHBaseCluster startMiniHBaseCluster(int numMasters, int numSlaves) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic MiniHBaseCluster startMiniHBaseCluster(int numMasters, int numSlaves, Class<? extends HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass, boolean create, boolean withWALDir) throws IOException, InterruptedException
startMiniCluster(int, int) when doing stepped startup of clusters.
 Usually you won't want this.  You'll usually want startMiniCluster().numMasters - numSlaves - create - Whether to create a
 root or data directory path or not; will overwrite if exists already.IOExceptionInterruptedException#startMiniCluster()}public void restartHBaseCluster(int servers)
                         throws IOException,
                                InterruptedException
servers - number of region serversIOExceptionInterruptedExceptionpublic MiniHBaseCluster getMiniHBaseCluster()
startMiniCluster().startMiniCluster()public void shutdownMiniCluster()
                         throws Exception
IOExceptionException#startMiniCluster(int)}public boolean cleanupTestDir()
                       throws IOException
cleanupTestDir in class HBaseCommonTestingUtilityIOExceptionpublic void shutdownMiniHBaseCluster()
                              throws IOException
IOExceptionpublic Path getDefaultRootDirPath(boolean create)
                           throws IOException
create
 is true, a new root directory path is fetched irrespective of whether it has been fetched
 before or not. If false, previous path is used.
 Note: this does not cause the root dir to be created.IOExceptionpublic Path getDefaultRootDirPath()
                           throws IOException
getDefaultRootDirPath(boolean create)
 except that create flag is false.
 Note: this does not cause the root dir to be created.IOExceptionpublic Path createRootDir(boolean create)
                   throws IOException
create - This flag decides whether to get a new
 root or data directory path or not, if it has been fetched already.
 Note : Directory will be made irrespective of whether path has been fetched or not.
 If directory already exists, it will be overwrittenIOExceptionpublic Path createRootDir()
                   throws IOException
createRootDir(boolean create)
 except that create flag is false.IOExceptionpublic Path createWALRootDir()
                      throws IOException
IOExceptionpublic void flush()
           throws IOException
IOExceptionpublic void flush(TableName tableName) throws IOException
IOExceptionpublic void compact(boolean major)
             throws IOException
IOExceptionpublic void compact(TableName tableName, boolean major) throws IOException
IOExceptionpublic Table createTable(TableName tableName, String family) throws IOException
tableName - family - IOExceptionpublic HTable createTable(byte[] tableName, byte[] family) throws IOException
tableName - family - IOExceptionpublic Table createTable(TableName tableName, String[] families) throws IOException
tableName - families - IOExceptionpublic HTable createTable(TableName tableName, byte[] family) throws IOException
tableName - family - IOExceptionpublic HTable createMultiRegionTable(TableName tableName, byte[] family, int numRegions) throws IOException
tableName - family - numRegions - IOExceptionpublic HTable createTable(byte[] tableName, byte[][] families) throws IOException
tableName - families - IOExceptionpublic HTable createTable(TableName tableName, byte[][] families) throws IOException
tableName - families - IOExceptionpublic HTable createMultiRegionTable(TableName tableName, byte[][] families) throws IOException
tableName - families - IOExceptionpublic HTable createTable(TableName tableName, byte[][] families, byte[][] splitKeys) throws IOException
tableName - families - splitKeys - IOExceptionpublic HTable createTable(byte[] tableName, byte[][] families, int numVersions, byte[] startKey, byte[] endKey, int numRegions) throws IOException
IOExceptionpublic HTable createTable(String tableName, byte[][] families, int numVersions, byte[] startKey, byte[] endKey, int numRegions) throws IOException
IOExceptionpublic HTable createTable(TableName tableName, byte[][] families, int numVersions, byte[] startKey, byte[] endKey, int numRegions) throws IOException
IOExceptionpublic HTable createTable(HTableDescriptor htd, byte[][] families, Configuration c) throws IOException
htd - families - c - Configuration to useIOExceptionpublic HTable createTable(HTableDescriptor htd, byte[][] families, byte[][] splitKeys, Configuration c) throws IOException
htd - families - splitKeys - c - Configuration to useIOExceptionpublic HTable createTable(HTableDescriptor htd, byte[][] splitRows) throws IOException
htd - splitRows - IOExceptionpublic HTable createTable(TableName tableName, byte[][] families, Configuration c) throws IOException
tableName - families - c - Configuration to useIOExceptionpublic HTable createTable(TableName tableName, byte[][] families, byte[][] splitKeys, Configuration c) throws IOException
tableName - families - splitKeys - c - Configuration to useIOExceptionpublic HTable createTable(byte[] tableName, byte[][] families, Configuration c) throws IOException
tableName - families - c - Configuration to useIOExceptionpublic HTable createTable(TableName tableName, byte[][] families, Configuration c, int numVersions) throws IOException
tableName - families - c - Configuration to usenumVersions - IOExceptionpublic HTable createTable(byte[] tableName, byte[][] families, Configuration c, int numVersions) throws IOException
tableName - families - c - Configuration to usenumVersions - IOExceptionpublic HTable createTable(byte[] tableName, byte[] family, int numVersions) throws IOException
tableName - family - numVersions - IOExceptionpublic HTable createTable(TableName tableName, byte[] family, int numVersions) throws IOException
tableName - family - numVersions - IOExceptionpublic HTable createTable(TableName tableName, byte[][] families, int numVersions, byte[][] splitKeys) throws IOException
tableName - families - numVersions - splitKeys - IOExceptionpublic HTable createMultiRegionTable(TableName tableName, byte[][] families, int numVersions) throws IOException
tableName - families - numVersions - IOExceptionpublic HTable createTable(byte[] tableName, byte[] family, byte[][] splitRows) throws IOException
tableName - family - splitRows - IOExceptionpublic HTable createTable(TableName tableName, byte[] family, byte[][] splitRows) throws IOException
tableName - family - splitRows - IOExceptionpublic HTable createMultiRegionTable(TableName tableName, byte[] family) throws IOException
tableName - family - IOExceptionpublic static WAL createWal(Configuration conf, Path rootDir, Path walRootDir, HRegionInfo hri) throws IOException
IOExceptionpublic static HRegion createRegionAndWAL(HRegionInfo info, Path rootDir, Path walRootDir, Configuration conf, HTableDescriptor htd) throws IOException
closeRegionAndWAL(HRegion) to clean up all resources.IOExceptionpublic static HRegion createRegionAndWAL(HRegionInfo info, Path rootDir, Path walRootDir, Configuration conf, HTableDescriptor htd, boolean initialize) throws IOException
closeRegionAndWAL(HRegion) to clean up all resources.IOExceptionpublic static void closeRegionAndWAL(Region r) throws IOException
r and it's underlying WAL. For use in tests.IOExceptionpublic static void closeRegionAndWAL(HRegion r) throws IOException
r and it's underlying WAL. For use in tests.IOExceptionpublic static void modifyTableSync(Admin admin, HTableDescriptor desc) throws IOException, InterruptedException
admin.rb#alter_status.IOExceptionInterruptedExceptionpublic static void setReplicas(Admin admin, TableName table, int replicaCount) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic void deleteTable(String tableName) throws IOException
tableName - existing tableIOExceptionpublic void deleteTable(byte[] tableName)
                 throws IOException
tableName - existing tableIOExceptionpublic void deleteTable(TableName tableName) throws IOException
tableName - existing tableIOExceptionpublic void deleteTableIfAny(TableName tableName) throws IOException
tableName - existing tableIOExceptionpublic HTableDescriptor createTableDescriptor(String name, int minVersions, int versions, int ttl, KeepDeletedCells keepDeleted)
name with COLUMNS for
 families.name - Name to give table.versions - How many versions to allow per column.public HTableDescriptor createTableDescriptor(String name)
name with COLUMNS for
 families.name - Name to give table.public HRegion createHRegion(HRegionInfo info, Path rootDir, Configuration conf, HTableDescriptor htd) throws IOException
closeRegion(Region)
 when you're finished with it.IOExceptionpublic HTableDescriptor createTableDescriptor(TableName tableName, byte[] family)
public HTableDescriptor createTableDescriptor(TableName tableName, byte[][] families, int maxVersions)
public HRegion createLocalHRegion(HTableDescriptor desc, byte[] startKey, byte[] endKey) throws IOException
desc - startKey - endKey - IOExceptionpublic HRegion createLocalHRegion(HRegionInfo info, HTableDescriptor desc) throws IOException
info - desc - IOExceptionpublic HRegion createLocalHRegion(HRegionInfo info, HTableDescriptor desc, WAL wal) throws IOException
info - regioninfodesc - table descriptorwal - wal for this region.IOExceptionpublic HRegion createLocalHRegion(byte[] tableName, byte[] startKey, byte[] stopKey, String callingMethod, Configuration conf, boolean isReadOnly, Durability durability, WAL wal, byte[]... families) throws IOException
tableName - startKey - stopKey - callingMethod - conf - isReadOnly - families - HRegion.closeHRegion(HRegion) when done.IOExceptionpublic HTable deleteTableData(byte[] tableName) throws IOException
tableName - existing tableIOExceptionpublic HTable deleteTableData(TableName tableName) throws IOException
tableName - existing tableIOExceptionpublic HTable truncateTable(TableName tableName, boolean preserveRegions) throws IOException
tableName - table which must exist.preserveRegions - keep the existing split pointsIOExceptionpublic HTable truncateTable(TableName tableName) throws IOException
tableName - table which must exist.IOExceptionpublic HTable truncateTable(byte[] tableName, boolean preserveRegions) throws IOException
tableName - table which must exist.preserveRegions - keep the existing split pointsIOExceptionpublic HTable truncateTable(byte[] tableName) throws IOException
tableName - table which must exist.IOExceptionpublic int loadTable(Table t, byte[] f) throws IOException
t - Tablef - FamilyIOExceptionpublic int loadTable(Table t, byte[] f, boolean writeToWAL) throws IOException
t - Tablef - FamilyIOExceptionpublic int loadTable(Table t, byte[][] f) throws IOException
t - Tablef - Array of Families to loadIOExceptionpublic int loadTable(Table t, byte[][] f, byte[] value) throws IOException
t - Tablef - Array of Families to loadvalue - the values of the cells. If null is passed, the row key is used as valueIOExceptionpublic int loadTable(Table t, byte[][] f, byte[] value, boolean writeToWAL) throws IOException
t - Tablef - Array of Families to loadvalue - the values of the cells. If null is passed, the row key is used as valueIOExceptionpublic int loadRegion(HRegion r, byte[] f) throws IOException
IOExceptionpublic int loadRegion(Region r, byte[] f) throws IOException
IOExceptionpublic int loadRegion(HRegion r, byte[] f, boolean flush) throws IOException
r - Regionf - Familyflush - flush the cache if trueIOExceptionpublic void loadNumericRows(Table t, byte[] f, int startRow, int endRow) throws IOException
IOExceptionpublic void verifyNumericRows(Table table, byte[] f, int startRow, int endRow, int replicaId) throws IOException
IOExceptionpublic void verifyNumericRows(Region region, byte[] f, int startRow, int endRow) throws IOException
IOExceptionpublic void verifyNumericRows(HRegion region, byte[] f, int startRow, int endRow) throws IOException
IOExceptionpublic void verifyNumericRows(Region region, byte[] f, int startRow, int endRow, boolean present) throws IOException
IOExceptionpublic void verifyNumericRows(HRegion region, byte[] f, int startRow, int endRow, boolean present) throws IOException
IOExceptionpublic void deleteNumericRows(HTable t, byte[] f, int startRow, int endRow) throws IOException
IOExceptionpublic int countRows(Table table) throws IOException
IOExceptionpublic int countRows(Table table, Scan scan) throws IOException
IOExceptionpublic int countRows(Table table, byte[]... families) throws IOException
IOExceptionpublic int countRows(TableName tableName) throws IOException
IOExceptionpublic String checksumRows(Table table) throws Exception
Exceptionpublic List<HRegionInfo> createMultiRegionsInMeta(Configuration conf, HTableDescriptor htd, byte[][] startKeys) throws IOException
conf - htd - startKeys - IOExceptionpublic List<byte[]> getMetaTableRows() throws IOException
IOException - When reading the rows fails.public List<byte[]> getMetaTableRows(TableName tableName) throws IOException
IOException - When reading the rows fails.public HRegionServer getRSForFirstRegionInTable(TableName tableName) throws IOException, InterruptedException
tableName - user table to lookup in hbase:metaIOExceptionInterruptedExceptionpublic MiniMRCluster startMiniMapReduceCluster()
                                        throws IOException
MiniMRCluster with a default number of
 TaskTracker's.IOException - When starting the cluster fails.public void shutdownMiniMapReduceCluster()
MiniMRCluster.public RegionServerServices createMockRegionServerService() throws IOException
IOExceptionpublic RegionServerServices createMockRegionServerService(RpcServerInterface rpc) throws IOException
IOExceptionpublic RegionServerServices createMockRegionServerService(ServerName name) throws IOException
IOExceptionpublic void enableDebug(Class<?> clazz)
clazz - The class for which to switch to debug logging.public void expireMasterSession()
                         throws Exception
Exceptionpublic void expireRegionServerSession(int index)
                               throws Exception
index - which RSExceptionpublic void expireSession(ZooKeeperWatcher nodeZK) throws Exception
Exception@Deprecated public void expireSession(ZooKeeperWatcher nodeZK, Server server) throws Exception
Exceptionpublic void expireSession(ZooKeeperWatcher nodeZK, boolean checkStatus) throws Exception
nodeZK - - the ZK watcher to expirecheckStatus - - true to check if we can create an HTable with the
                    current configuration.Exceptionpublic MiniHBaseCluster getHBaseCluster()
getHBaseClusterInterface()public HBaseCluster getHBaseClusterInterface()
Returned object can be any of the subclasses of HBaseCluster, and the
 tests referring this should not assume that the cluster is a mini cluster or a
 distributed one. If the test only works on a mini cluster, then specific
 method getMiniHBaseCluster() can be used instead w/o the
 need to type-cast.
public Connection getConnection() throws IOException
IOExceptionpublic HBaseAdmin getHBaseAdmin() throws IOException
IOExceptionpublic ZooKeeperWatcher getZooKeeperWatcher() throws IOException
IOExceptionpublic void closeRegion(String regionName) throws IOException
regionName - The region to close.IOExceptionpublic void closeRegion(byte[] regionName)
                 throws IOException
regionName - The region to close.IOExceptionpublic void closeRegionByRow(String row, RegionLocator table) throws IOException
row - The row to find the containing region.table - The table to find the region.IOExceptionpublic void closeRegionByRow(byte[] row,
                             RegionLocator table)
                      throws IOException
row - The row to find the containing region.table - The table to find the region.IOExceptionpublic MiniZooKeeperCluster getZkCluster()
public void setZkCluster(MiniZooKeeperCluster zkCluster)
public MiniDFSCluster getDFSCluster()
public void setDFSCluster(MiniDFSCluster cluster)
                   throws IllegalStateException,
                          IOException
IllegalStateExceptionIOExceptionpublic void setDFSCluster(MiniDFSCluster cluster,
                          boolean requireDown)
                   throws IllegalStateException,
                          IOException
cluster - cluster to userequireDown - require the that cluster not be "up" (MiniDFSCluster#isClusterUp) before
 it is set.IllegalStateException - if the passed cluster is up when it is required to be downIOException - if the FileSystem could not be set from the passed dfs clusterpublic FileSystem getTestFileSystem()
                             throws IOException
IOExceptionpublic void waitTableAvailable(TableName table) throws InterruptedException, IOException
table - Table to wait on.InterruptedExceptionIOExceptionpublic void waitTableAvailable(TableName table, long timeoutMillis) throws InterruptedException, IOException
InterruptedExceptionIOExceptionpublic String explainTableAvailability(TableName tableName) throws IOException
IOExceptionpublic String explainTableState(TableName tableName) throws IOException
IOExceptionpublic void waitTableAvailable(byte[] table,
                               long timeoutMillis)
                        throws InterruptedException,
                               IOException
table - Table to wait on.timeoutMillis - Timeout.InterruptedExceptionIOExceptionpublic void waitTableAvailable(Admin admin, byte[] table, long timeoutMillis) throws InterruptedException, IOException
InterruptedExceptionIOExceptionpublic void waitTableEnabled(TableName table) throws InterruptedException, IOException
table - Table to wait on.table - InterruptedExceptionIOException#waitTableAvailable(byte[])public void waitTableEnabled(byte[] table,
                             long timeoutMillis)
                      throws InterruptedException,
                             IOException
table - Table to wait on.timeoutMillis - Time to wait on it being marked enabled.InterruptedExceptionIOException#waitTableAvailable(byte[])public void waitTableEnabled(TableName table, long timeoutMillis) throws IOException
IOExceptionpublic void waitTableDisabled(byte[] table)
                       throws InterruptedException,
                              IOException
table - Table to wait on.InterruptedExceptionIOExceptionpublic void waitTableDisabled(Admin admin, byte[] table) throws InterruptedException, IOException
InterruptedExceptionIOExceptionpublic void waitTableDisabled(byte[] table,
                              long timeoutMillis)
                       throws InterruptedException,
                              IOException
table - Table to wait on.timeoutMillis - Time to wait on it being marked disabled.InterruptedExceptionIOExceptionpublic void waitTableDisabled(Admin admin, byte[] table, long timeoutMillis) throws InterruptedException, IOException
InterruptedExceptionIOExceptionpublic boolean ensureSomeRegionServersAvailable(int num)
                                         throws IOException
num - minimum number of region servers that should be runningIOExceptionpublic boolean ensureSomeNonStoppedRegionServersAvailable(int num)
                                                   throws IOException
num - minimum number of region servers that should be runningIOExceptionpublic static User getDifferentUser(Configuration c, String differentiatingSuffix) throws IOException
c configuration setting a new
 user into the clone.  Use it getting new instances of FileSystem.  Only
 works for DistributedFileSystem.c - Initial configurationdifferentiatingSuffix - Suffix to differentiate this user from others.IOExceptionpublic static NavigableSet<String> getAllOnlineRegions(MiniHBaseCluster cluster) throws IOException
IOExceptionpublic static void setMaxRecoveryErrorCount(OutputStream stream, int max)
2010-06-15 11:52:28,511 WARN [DataStreamer for file /hbase/.logs/wal.1276627923013 block blk_928005470262850423_1021] hdfs.DFSClient$DFSOutputStream(2657): Error Recovery for block blk_928005470262850423_1021 failed because recovery from primary datanode 127.0.0.1:53683 failed 4 times. Pipeline was 127.0.0.1:53687, 127.0.0.1:53683. Will retry...
stream - A DFSClient.DFSOutputStream.max - NoSuchFieldExceptionSecurityExceptionIllegalAccessExceptionIllegalArgumentExceptionpublic void waitUntilAllRegionsAssigned(TableName tableName) throws IOException
tableName - the table nameIOExceptionpublic void waitUntilAllSystemRegionsAssigned()
                                       throws IOException
IOExceptionpublic void waitUntilAllRegionsAssigned(TableName tableName, long timeout) throws IOException
tableName - the table nametimeout - timeout, in millisecondsIOExceptionpublic static List<Cell> getFromStoreFile(HStore store, Get get) throws IOException
IOExceptionpublic byte[][] getRegionSplitStartKeys(byte[] startKey,
                                        byte[] endKey,
                                        int numRegions)
startKey - endKey - numRegions - the number of regions to be created. it has to be greater than 3.public static List<Cell> getFromStoreFile(HStore store, byte[] row, NavigableSet<byte[]> columns) throws IOException
IOExceptionpublic static ZooKeeperWatcher getZooKeeperWatcher(HBaseTestingUtility TEST_UTIL) throws ZooKeeperConnectionException, IOException
TEST_UTIL - ZooKeeperConnectionExceptionIOExceptionpublic static ZooKeeperWatcher createAndForceNodeToOpenedState(HBaseTestingUtility TEST_UTIL, Region region, ServerName serverName) throws ZooKeeperConnectionException, IOException, KeeperException, NodeExistsException
TEST_UTIL - region - serverName - IOExceptionZooKeeperConnectionExceptionKeeperExceptionNodeExistsExceptionpublic static ZooKeeperWatcher createAndForceNodeToOpenedState(HBaseTestingUtility TEST_UTIL, HRegion region, ServerName serverName) throws ZooKeeperConnectionException, IOException, KeeperException, NodeExistsException
TEST_UTIL - region - serverName - IOExceptionZooKeeperConnectionExceptionKeeperExceptionNodeExistsExceptionpublic static void assertKVListsEqual(String additionalMsg, List<? extends Cell> expected, List<? extends Cell> actual)
public String getClusterKey()
public HTable createRandomTable(String tableName, Collection<String> families, int maxVersions, int numColsPerRow, int numFlushes, int numRegions, int numRowsPerFlush) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic static int randomPort()
public static int randomFreePort()
public static String randomMultiCastAddress()
public static void waitForHostPort(String host, int port) throws IOException
IOExceptionpublic static int createPreSplitLoadTestTable(Configuration conf,
                                              TableName tableName,
                                              byte[] columnFamily,
                                              Compression.Algorithm compression,
                                              DataBlockEncoding dataBlockEncoding)
                                       throws IOException
IOExceptionpublic static int createPreSplitLoadTestTable(Configuration conf,
                                              TableName tableName,
                                              byte[] columnFamily,
                                              Compression.Algorithm compression,
                                              DataBlockEncoding dataBlockEncoding,
                                              int numRegionsPerServer,
                                              int regionReplication,
                                              Durability durability)
                                       throws IOException
IOExceptionpublic static int createPreSplitLoadTestTable(Configuration conf,
                                              TableName tableName,
                                              byte[][] columnFamilies,
                                              Compression.Algorithm compression,
                                              DataBlockEncoding dataBlockEncoding,
                                              int numRegionsPerServer,
                                              int regionReplication,
                                              Durability durability)
                                       throws IOException
IOExceptionpublic static int createPreSplitLoadTestTable(Configuration conf,
                                              HTableDescriptor desc,
                                              HColumnDescriptor hcd)
                                       throws IOException
IOExceptionpublic static int createPreSplitLoadTestTable(Configuration conf,
                                              HTableDescriptor desc,
                                              HColumnDescriptor hcd,
                                              int numRegionsPerServer)
                                       throws IOException
IOExceptionpublic static int createPreSplitLoadTestTable(Configuration conf,
                                              HTableDescriptor desc,
                                              HColumnDescriptor[] hcds,
                                              int numRegionsPerServer)
                                       throws IOException
IOExceptionpublic static int getMetaRSPort(Configuration conf)
                         throws IOException
IOExceptionpublic void assertRegionOnServer(HRegionInfo hri, ServerName server, long timeout) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic void assertRegionOnlyOnServer(HRegionInfo hri, ServerName server, long timeout) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic HRegion createTestRegion(String tableName, HColumnDescriptor hcd) throws IOException
IOExceptionpublic void setFileSystemURI(String fsURI)
public <E extends Exception> long waitFor(long timeout, Waiter.Predicate<E> predicate) throws E extends Exception
Waiter.waitFor(Configuration, long, Predicate).E extends Exceptionpublic <E extends Exception> long waitFor(long timeout, long interval, Waiter.Predicate<E> predicate) throws E extends Exception
Waiter.waitFor(Configuration, long, long, Predicate).E extends Exceptionpublic <E extends Exception> long waitFor(long timeout, long interval, boolean failIfTimeout, Waiter.Predicate<E> predicate) throws E extends Exception
Waiter.waitFor(Configuration, long, long, boolean, Predicate).E extends Exceptionpublic Waiter.ExplainingPredicate<IOException> predicateNoRegionsInTransition()
Waiter.Predicate for checking that there are no regions in transition in masterpublic Waiter.Predicate<IOException> predicateTableEnabled(TableName tableName)
Waiter.Predicate for checking that table is enabledpublic Waiter.Predicate<IOException> predicateTableDisabled(TableName tableName)
Waiter.Predicate for checking that table is enabledpublic Waiter.Predicate<IOException> predicateTableAvailable(TableName tableName)
Waiter.Predicate for checking that table is enabledpublic void waitUntilNoRegionsInTransition(long timeout)
                                    throws Exception
timeout - How long to wait.Exceptionpublic void waitLabelAvailable(long timeoutMillis,
                               String... labels)
timeoutMillis - labels - public static List<HColumnDescriptor> generateColumnDescriptors()
public static List<HColumnDescriptor> generateColumnDescriptors(String prefix)
prefix - family names prefixpublic static Compression.Algorithm[] getSupportedCompressionAlgorithms()