Package org.apache.hadoop.hbase.snapshot
Class SnapshotTestingUtils
java.lang.Object
org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils
Utilities class for snapshots
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<org.apache.hadoop.hbase.client.SnapshotDescription>
assertExistsMatchingSnapshot
(org.apache.hadoop.hbase.client.Admin admin, String snapshotName, org.apache.hadoop.hbase.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
(org.apache.hadoop.hbase.client.Admin admin) Assert that we don't have any snapshots lists if the admin operation failsstatic List<org.apache.hadoop.hbase.client.SnapshotDescription>
assertOneSnapshotThatMatches
(org.apache.hadoop.hbase.client.Admin admin, byte[] snapshot, org.apache.hadoop.hbase.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 List<org.apache.hadoop.hbase.client.SnapshotDescription>
assertOneSnapshotThatMatches
(org.apache.hadoop.hbase.client.Admin admin, String snapshotName, org.apache.hadoop.hbase.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
(org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot) Make sure that there is only one snapshot returned from the masterstatic void
cleanupSnapshot
(org.apache.hadoop.hbase.client.Admin admin, byte[] tableName) static void
cleanupSnapshot
(org.apache.hadoop.hbase.client.Admin admin, String snapshotName) static void
confirmEmptySnapshotValid
(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDescriptor, org.apache.hadoop.hbase.TableName tableName, byte[] testFamily, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.fs.FileSystem fs) Confirm that the snapshot has no references files but only metadata.static void
confirmSnapshotValid
(HBaseTestingUtility testUtil, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDescriptor, org.apache.hadoop.hbase.TableName tableName, byte[] family) static void
confirmSnapshotValid
(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDescriptor, org.apache.hadoop.hbase.TableName tableName, byte[] testFamily, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.fs.FileSystem fs) Confirm that the snapshot contains references to all the files that should be in the snapshot.static void
confirmSnapshotValid
(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDescriptor, org.apache.hadoop.hbase.TableName tableName, List<byte[]> nonEmptyTestFamilies, List<byte[]> emptyTestFamilies, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.fs.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
createPreSplitTable
(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, int nRegions, byte[]... families) private static org.apache.hadoop.hbase.client.Put
createPut
(byte[][] families, byte[] key, byte[] value) static void
createSnapshotAndValidate
(org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.TableName tableName, String familyName, String snapshotNameString, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.FileSystem fs, boolean onlineSnapshot) Take a snapshot of the specified table and verify that the given family is not empty.static void
createSnapshotAndValidate
(org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames, String snapshotNameString, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.FileSystem fs, boolean onlineSnapshot) Take a snapshot of the specified table and verify the given families.static void
createTable
(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, byte[]... families) static void
createTable
(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, int regionReplication, byte[]... families) static void
createTable
(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, int regionReplication, int nRegions, byte[]... families) static void
deleteAllSnapshots
(org.apache.hadoop.hbase.client.Admin admin) static void
static void
expectSnapshotDoneException
(org.apache.hadoop.hbase.master.HMaster master, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneRequest snapshot, Class<? extends org.apache.hadoop.hbase.snapshot.HBaseSnapshotException> clazz) Expect the snapshot to throw an error when checking if the snapshot is completestatic byte[][]
static byte[][]
getSplitKeys
(int nRegions) listHFileNames
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir) List all the HFiles in the given tablestatic void
loadData
(HBaseTestingUtility util, org.apache.hadoop.hbase.client.BufferedMutator mutator, int rows, byte[]... families) static void
loadData
(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, int rows, byte[]... families) static void
snapshot
(org.apache.hadoop.hbase.client.Admin admin, String snapshotName, org.apache.hadoop.hbase.TableName tableName, org.apache.hadoop.hbase.client.SnapshotType type, int numTries) static void
snapshot
(org.apache.hadoop.hbase.client.Admin admin, String snapshotName, org.apache.hadoop.hbase.TableName tableName, org.apache.hadoop.hbase.client.SnapshotType type, int numTries, Map<String, Object> snapshotProps) static void
verifyReplicasCameOnline
(org.apache.hadoop.hbase.TableName tableName, org.apache.hadoop.hbase.client.Admin admin, int regionReplication) static void
verifyRowCount
(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, long expectedRows) static void
waitForTableToBeOnline
(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName)
-
Field Details
-
LOG
-
KEYS
-
-
Constructor Details
-
SnapshotTestingUtils
private SnapshotTestingUtils()
-
-
Method Details
-
assertNoSnapshots
Assert that we don't have any snapshots lists if the admin operation fails- Throws:
IOException
-
assertExistsMatchingSnapshot
public static List<org.apache.hadoop.hbase.client.SnapshotDescription> assertExistsMatchingSnapshot(org.apache.hadoop.hbase.client.Admin admin, String snapshotName, org.apache.hadoop.hbase.TableName tableName) throws IOException Make sure that there is only one snapshot returned from the master and its name and table match the passed in parameters.- Throws:
IOException
-
assertOneSnapshotThatMatches
public static void assertOneSnapshotThatMatches(org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot) throws IOException Make sure that there is only one snapshot returned from the master- Throws:
IOException
-
assertOneSnapshotThatMatches
public static List<org.apache.hadoop.hbase.client.SnapshotDescription> assertOneSnapshotThatMatches(org.apache.hadoop.hbase.client.Admin admin, String snapshotName, org.apache.hadoop.hbase.TableName tableName) throws IOException Make sure that there is only one snapshot returned from the master and its name and table match the passed in parameters.- Throws:
IOException
-
assertOneSnapshotThatMatches
public static List<org.apache.hadoop.hbase.client.SnapshotDescription> assertOneSnapshotThatMatches(org.apache.hadoop.hbase.client.Admin admin, byte[] snapshot, org.apache.hadoop.hbase.TableName tableName) throws IOException Make sure that there is only one snapshot returned from the master and its name and table match the passed in parameters.- Throws:
IOException
-
confirmSnapshotValid
public static void confirmSnapshotValid(HBaseTestingUtility testUtil, org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDescriptor, org.apache.hadoop.hbase.TableName tableName, byte[] family) throws IOException - Throws:
IOException
-
confirmSnapshotValid
public static void confirmSnapshotValid(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDescriptor, org.apache.hadoop.hbase.TableName tableName, byte[] testFamily, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.fs.FileSystem fs) throws IOException Confirm that the snapshot contains references to all the files that should be in the snapshot.- Throws:
IOException
-
confirmEmptySnapshotValid
public static void confirmEmptySnapshotValid(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDescriptor, org.apache.hadoop.hbase.TableName tableName, byte[] testFamily, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.fs.FileSystem fs) throws IOException Confirm that the snapshot has no references files but only metadata.- Throws:
IOException
-
confirmSnapshotValid
public static void confirmSnapshotValid(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshotDescriptor, org.apache.hadoop.hbase.TableName tableName, List<byte[]> nonEmptyTestFamilies, List<byte[]> emptyTestFamilies, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.fs.FileSystem fs) throws IOException Confirm that the snapshot contains references to all the files that should be in the snapshot. This method also perform some redundant check like the existence of the snapshotinfo or the regioninfo which are done always by the MasterSnapshotVerifier, at the end of the snapshot operation.- Throws:
IOException
-
snapshot
public static void snapshot(org.apache.hadoop.hbase.client.Admin admin, String snapshotName, org.apache.hadoop.hbase.TableName tableName, org.apache.hadoop.hbase.client.SnapshotType type, int numTries) throws IOException - Throws:
IOException
-
snapshot
public static void snapshot(org.apache.hadoop.hbase.client.Admin admin, String snapshotName, org.apache.hadoop.hbase.TableName tableName, org.apache.hadoop.hbase.client.SnapshotType type, int numTries, Map<String, Object> snapshotProps) throws IOException- Throws:
IOException
-
cleanupSnapshot
public static void cleanupSnapshot(org.apache.hadoop.hbase.client.Admin admin, byte[] tableName) throws IOException - Throws:
IOException
-
cleanupSnapshot
public static void cleanupSnapshot(org.apache.hadoop.hbase.client.Admin admin, String snapshotName) throws IOException - Throws:
IOException
-
expectSnapshotDoneException
public static void expectSnapshotDoneException(org.apache.hadoop.hbase.master.HMaster master, org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.IsSnapshotDoneRequest snapshot, Class<? extends org.apache.hadoop.hbase.snapshot.HBaseSnapshotException> clazz) Expect the snapshot to throw an error when checking if the snapshot is complete- Parameters:
master
- master to checksnapshot
- theSnapshotDescription
request to pass to the masterclazz
- expected exception from the master
-
listHFileNames
public static ArrayList<String> listHFileNames(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir) throws IOException List all the HFiles in the given table- Parameters:
fs
- FileSystem where the table livestableDir
- directory of the table- Returns:
- array of the current HFiles in the table (could be a zero-length array)
- Throws:
IOException
- on unexecpted error reading the FS
-
createSnapshotAndValidate
public static void createSnapshotAndValidate(org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.TableName tableName, String familyName, String snapshotNameString, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.FileSystem fs, boolean onlineSnapshot) throws Exception Take a snapshot of the specified table and verify that the given family is not empty. Note that this will leave the table disabled in the case of an offline snapshot.- Throws:
Exception
-
createSnapshotAndValidate
public static void createSnapshotAndValidate(org.apache.hadoop.hbase.client.Admin admin, org.apache.hadoop.hbase.TableName tableName, List<byte[]> nonEmptyFamilyNames, List<byte[]> emptyFamilyNames, String snapshotNameString, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.FileSystem fs, boolean onlineSnapshot) throws Exception Take a snapshot of the specified table and verify the given families. Note that this will leave the table disabled in the case of an offline snapshot.- Throws:
Exception
-
corruptSnapshot
public static ArrayList corruptSnapshot(HBaseTestingUtility util, String snapshotName) throws IOException Corrupt the specified snapshot by deleting some files.- Parameters:
util
-HBaseTestingUtility
snapshotName
- name of the snapshot to corrupt- Returns:
- array of the corrupted HFiles
- Throws:
IOException
- on unexecpted error reading the FS
-
waitForTableToBeOnline
public static void waitForTableToBeOnline(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
createTable
public static void createTable(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, int regionReplication, int nRegions, byte[]... families) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
getSplitKeys
-
getSplitKeys
-
createTable
public static void createTable(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, byte[]... families) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
createTable
public static void createTable(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, int regionReplication, byte[]... families) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
createPreSplitTable
public static void createPreSplitTable(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, int nRegions, byte[]... families) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
loadData
public static void loadData(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, int rows, byte[]... families) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
loadData
public static void loadData(HBaseTestingUtility util, org.apache.hadoop.hbase.client.BufferedMutator mutator, int rows, byte[]... families) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
createPut
private static org.apache.hadoop.hbase.client.Put createPut(byte[][] families, byte[] key, byte[] value) -
deleteAllSnapshots
public static void deleteAllSnapshots(org.apache.hadoop.hbase.client.Admin admin) throws IOException - Throws:
IOException
-
deleteArchiveDirectory
- Throws:
IOException
-
verifyRowCount
public static void verifyRowCount(HBaseTestingUtility util, org.apache.hadoop.hbase.TableName tableName, long expectedRows) throws IOException - Throws:
IOException
-
verifyReplicasCameOnline
public static void verifyReplicasCameOnline(org.apache.hadoop.hbase.TableName tableName, org.apache.hadoop.hbase.client.Admin admin, int regionReplication) throws IOException - Throws:
IOException
-