public class SnapshotTestingUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
SnapshotTestingUtils.SnapshotMock |
Constructor and Description |
---|
SnapshotTestingUtils() |
Modifier and Type | Method and Description |
---|---|
static List<HBaseProtos.SnapshotDescription> |
assertExistsMatchingSnapshot(Admin admin,
String snapshotName,
TableName tableName)
Make sure that there is only one snapshot returned from the master and its
name and table match the passed in parameters.
|
static void |
assertNoSnapshots(Admin admin)
Assert that we don't have any snapshots lists
|
static List<HBaseProtos.SnapshotDescription> |
assertOneSnapshotThatMatches(Admin admin,
byte[] snapshot,
TableName tableName)
Make sure that there is only one snapshot returned from the master and its
name and table match the passed in parameters.
|
static void |
assertOneSnapshotThatMatches(Admin admin,
HBaseProtos.SnapshotDescription snapshot)
Make sure that there is only one snapshot returned from the master
|
static List<HBaseProtos.SnapshotDescription> |
assertOneSnapshotThatMatches(Admin admin,
String snapshotName,
TableName tableName)
Make sure that there is only one snapshot returned from the master and its
name and table match the passed in parameters.
|
static void |
cleanupSnapshot(Admin admin,
byte[] tableName) |
static void |
cleanupSnapshot(Admin admin,
String snapshotName) |
static void |
confirmEmptySnapshotValid(HBaseProtos.SnapshotDescription snapshotDescriptor,
TableName tableName,
byte[] testFamily,
Path rootDir,
Admin admin,
FileSystem fs)
Confirm that the snapshot has no references files but only metadata.
|
static void |
confirmSnapshotValid(HBaseProtos.SnapshotDescription snapshotDescriptor,
TableName tableName,
byte[] testFamily,
Path rootDir,
Admin admin,
FileSystem fs)
Confirm that the snapshot contains references to all the files that should
be in the snapshot.
|
static void |
confirmSnapshotValid(HBaseProtos.SnapshotDescription snapshotDescriptor,
TableName tableName,
List<byte[]> nonEmptyTestFamilies,
List<byte[]> emptyTestFamilies,
Path rootDir,
Admin admin,
FileSystem fs)
Confirm that the snapshot contains references to all the files that should
be in the snapshot.
|
static ArrayList |
corruptSnapshot(HBaseTestingUtility util,
String snapshotName)
Corrupt the specified snapshot by deleting some files.
|
static void |
createSnapshotAndValidate(Admin admin,
TableName tableName,
List<byte[]> nonEmptyFamilyNames,
List<byte[]> emptyFamilyNames,
String snapshotNameString,
Path rootDir,
FileSystem fs,
boolean onlineSnapshot)
Take a snapshot of the specified table and verify the given families.
|
static void |
createSnapshotAndValidate(Admin admin,
TableName tableName,
String familyName,
String snapshotNameString,
Path rootDir,
FileSystem fs,
boolean onlineSnapshot)
Take a snapshot of the specified table and verify that the given family is
not empty.
|
static void |
createTable(HBaseTestingUtility util,
TableName tableName,
byte[]... families) |
static void |
createTable(HBaseTestingUtility util,
TableName tableName,
int regionReplication,
byte[]... families) |
static void |
deleteAllSnapshots(Admin admin) |
static void |
deleteArchiveDirectory(HBaseTestingUtility util) |
static void |
expectSnapshotDoneException(HMaster master,
MasterProtos.IsSnapshotDoneRequest snapshot,
Class<? extends HBaseSnapshotException> clazz)
Expect the snapshot to throw an error when checking if the snapshot is
complete
|
static byte[][] |
getSplitKeys() |
static String[] |
listHFileNames(FileSystem fs,
Path tableDir) |
static Path[] |
listHFiles(FileSystem fs,
Path tableDir)
List all the HFiles in the given table
|
static void |
loadData(HBaseTestingUtility util,
BufferedMutator mutator,
int rows,
byte[]... families) |
static void |
loadData(HBaseTestingUtility util,
TableName tableName,
int rows,
byte[]... families) |
static void |
snapshot(Admin admin,
String snapshotName,
String tableName,
HBaseProtos.SnapshotDescription.Type type,
int numTries) |
static void |
verifyReplicasCameOnline(TableName tableName,
Admin admin,
int regionReplication) |
static void |
verifyRowCount(HBaseTestingUtility util,
TableName tableName,
long expectedRows) |
static void |
waitForSnapshotToComplete(HMaster master,
HBaseProtos.SnapshotDescription snapshot,
long sleep)
Helper method for testing async snapshot operations.
|
static void |
waitForTableToBeOnline(HBaseTestingUtility util,
TableName tableName) |
public static void assertNoSnapshots(Admin admin) throws IOException
IOException
- if the admin operation failspublic static List<HBaseProtos.SnapshotDescription> assertExistsMatchingSnapshot(Admin admin, String snapshotName, TableName tableName) throws IOException
IOException
public static void assertOneSnapshotThatMatches(Admin admin, HBaseProtos.SnapshotDescription snapshot) throws IOException
IOException
public static List<HBaseProtos.SnapshotDescription> assertOneSnapshotThatMatches(Admin admin, String snapshotName, TableName tableName) throws IOException
IOException
public static List<HBaseProtos.SnapshotDescription> assertOneSnapshotThatMatches(Admin admin, byte[] snapshot, TableName tableName) throws IOException
IOException
public static void confirmSnapshotValid(HBaseProtos.SnapshotDescription snapshotDescriptor, TableName tableName, byte[] testFamily, Path rootDir, Admin admin, FileSystem fs) throws IOException
IOException
public static void confirmEmptySnapshotValid(HBaseProtos.SnapshotDescription snapshotDescriptor, TableName tableName, byte[] testFamily, Path rootDir, Admin admin, FileSystem fs) throws IOException
IOException
public static void confirmSnapshotValid(HBaseProtos.SnapshotDescription snapshotDescriptor, TableName tableName, List<byte[]> nonEmptyTestFamilies, List<byte[]> emptyTestFamilies, Path rootDir, Admin admin, FileSystem fs) throws IOException
IOException
public static void waitForSnapshotToComplete(HMaster master, HBaseProtos.SnapshotDescription snapshot, long sleep) throws ServiceException
master:
- the master running the snapshotsnapshot:
- the snapshot to checksleep:
- amount to sleep between checks to see if the snapshot is doneServiceException
- if the snapshot failspublic static void snapshot(Admin admin, String snapshotName, String tableName, HBaseProtos.SnapshotDescription.Type type, int numTries) throws IOException
IOException
public static void cleanupSnapshot(Admin admin, byte[] tableName) throws IOException
IOException
public static void cleanupSnapshot(Admin admin, String snapshotName) throws IOException
IOException
public static void expectSnapshotDoneException(HMaster master, MasterProtos.IsSnapshotDoneRequest snapshot, Class<? extends HBaseSnapshotException> clazz)
master
- master to checksnapshot
- the HBaseProtos.SnapshotDescription
request to pass to the masterclazz
- expected exception from the masterpublic static Path[] listHFiles(FileSystem fs, Path tableDir) throws IOException
fs:
- FileSystem where the table livestableDir
- directory of the tableIOException
- on unexecpted error reading the FSpublic static String[] listHFileNames(FileSystem fs, Path tableDir) throws IOException
IOException
public static void createSnapshotAndValidate(Admin admin, TableName tableName, String familyName, String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot) throws Exception
Exception
public static void createSnapshotAndValidate(Admin admin, TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames, String snapshotNameString, Path rootDir, FileSystem fs, boolean onlineSnapshot) throws Exception
Exception
public static ArrayList corruptSnapshot(HBaseTestingUtility util, String snapshotName) throws IOException
util
- HBaseTestingUtility
snapshotName
- name of the snapshot to corruptIOException
- on unexecpted error reading the FSpublic static void waitForTableToBeOnline(HBaseTestingUtility util, TableName tableName) throws IOException, InterruptedException
IOException
InterruptedException
public static void createTable(HBaseTestingUtility util, TableName tableName, int regionReplication, byte[]... families) throws IOException, InterruptedException
IOException
InterruptedException
public static byte[][] getSplitKeys()
public static void createTable(HBaseTestingUtility util, TableName tableName, byte[]... families) throws IOException, InterruptedException
IOException
InterruptedException
public static void loadData(HBaseTestingUtility util, TableName tableName, int rows, byte[]... families) throws IOException, InterruptedException
IOException
InterruptedException
public static void loadData(HBaseTestingUtility util, BufferedMutator mutator, int rows, byte[]... families) throws IOException, InterruptedException
IOException
InterruptedException
public static void deleteAllSnapshots(Admin admin) throws IOException
IOException
public static void deleteArchiveDirectory(HBaseTestingUtility util) throws IOException
IOException
public static void verifyRowCount(HBaseTestingUtility util, TableName tableName, long expectedRows) throws IOException
IOException
public static void verifyReplicasCameOnline(TableName tableName, Admin admin, int regionReplication) throws IOException
IOException