Class TestContinuousBackupReplicationEndpoint
java.lang.Object
org.apache.hadoop.hbase.backup.replication.TestContinuousBackupReplicationEndpoint
@Tag("org.apache.hadoop.hbase.testclassification.ReplicationTests") @Tag("org.apache.hadoop.hbase.testclassification.LargeTests")
public class TestContinuousBackupReplicationEndpoint
extends Object
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classReplication endpoint that fails only once on first upload attempt, then succeeds on retry.static classReplication endpoint that simulates leaving a partial file behind on first attempt, then succeeds on second attempt by overwriting it. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static org.apache.hadoop.hbase.client.Adminprivate static final Stringprivate static final org.apache.hadoop.conf.Configuration(package private) static org.apache.hadoop.fs.FileSystemprivate static final org.slf4j.Loggerprivate static final byte[]private final String(package private) static org.apache.hadoop.fs.Pathprivate static final HBaseTestingUtil -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddReplicationPeer(String peerId, org.apache.hadoop.fs.Path backupRootDir, Map<org.apache.hadoop.hbase.TableName, List<String>> tableMap) private voidaddReplicationPeer(String peerId, org.apache.hadoop.fs.Path backupRootDir, Map<org.apache.hadoop.hbase.TableName, List<String>> tableMap, String customReplicationEndpointImpl) private voidbulkLoadHFiles(org.apache.hadoop.hbase.TableName tableName, Map<byte[], List<org.apache.hadoop.fs.Path>> family2Files) private voidbulkLoadHFiles(org.apache.hadoop.hbase.TableName tableName, org.apache.hadoop.fs.Path inputDir) private voidcreateTable(org.apache.hadoop.hbase.TableName tableName) private voiddeleteReplicationPeer(String peerId) private voiddeleteTable(org.apache.hadoop.hbase.TableName tableName) private voidgenerateHFiles(org.apache.hadoop.fs.Path outputDir) private intgetRowCount(org.apache.hadoop.hbase.TableName tableName) private voidloadRandomData(org.apache.hadoop.hbase.TableName tableName, int totalRows) private voidreplayBulkLoadHFilesIfPresent(String bulkLoadDir, org.apache.hadoop.hbase.TableName tableName) private voidreplayWALs(String walDir, org.apache.hadoop.hbase.TableName tableName) static voidstatic voidvoidSimulates a one-time failure during bulk load file upload.voidSimulates a stale/partial file left behind after a failed bulk load.voidUnit test for verifying cleanup of partial files.voidvoidvoidvoidprivate voidverifyBackup(String backupRootDir, boolean hasBulkLoadFiles, Map<org.apache.hadoop.hbase.TableName, Integer> tablesWithExpectedRows) Verifies the backup process by: 1.private voidverifyBulkLoadBackup(String backupRootDir) private voidverifyWALBackup(String backupRootDir) private voidwaitForReplication(int durationInMillis)
-
Field Details
-
LOG
-
TEST_UTIL
-
conf
-
admin
-
replicationEndpoint
-
CF_NAME
- See Also:
-
QUALIFIER
-
fs
-
root
-
-
Constructor Details
-
TestContinuousBackupReplicationEndpoint
-
-
Method Details
-
setUpBeforeClass
- Throws:
Exception
-
tearDownAfterClass
- Throws:
Exception
-
testWALAndBulkLoadFileBackup
- Throws:
IOException
-
testMultiTableWALBackup
- Throws:
IOException
-
testWALBackupWithPeerRestart
- Throws:
IOExceptionInterruptedException
-
testDayWiseWALBackup
- Throws:
IOException
-
testBulkLoadFileUploadRetry
Simulates a one-time failure during bulk load file upload. This validates that the retry logic in the replication endpoint works as expected.- Throws:
IOException
-
testCopyWithCleanupDeletesPartialFile
Unit test for verifying cleanup of partial files. Simulates a failure duringFileUtil.copy(FileSystem, Path, FileSystem, Path, boolean, boolean, Configuration)and checks that the destination file is deleted.- Throws:
Exception
-
testBulkLoadFileUploadWithStaleFileRetry
Simulates a stale/partial file left behind after a failed bulk load. On retry, the stale file should be overwritten and replication succeeds.- Throws:
Exception
-
createTable
- Throws:
IOException
-
deleteTable
- Throws:
IOException
-
addReplicationPeer
private void addReplicationPeer(String peerId, org.apache.hadoop.fs.Path backupRootDir, Map<org.apache.hadoop.hbase.TableName, List<String>> tableMap) throws IOException- Throws:
IOException
-
addReplicationPeer
private void addReplicationPeer(String peerId, org.apache.hadoop.fs.Path backupRootDir, Map<org.apache.hadoop.hbase.TableName, List<String>> tableMap, String customReplicationEndpointImpl) throws IOException- Throws:
IOException
-
deleteReplicationPeer
- Throws:
IOException
-
loadRandomData
private void loadRandomData(org.apache.hadoop.hbase.TableName tableName, int totalRows) throws IOException - Throws:
IOException
-
bulkLoadHFiles
private void bulkLoadHFiles(org.apache.hadoop.hbase.TableName tableName, org.apache.hadoop.fs.Path inputDir) throws IOException - Throws:
IOException
-
bulkLoadHFiles
private void bulkLoadHFiles(org.apache.hadoop.hbase.TableName tableName, Map<byte[], List<org.apache.hadoop.fs.Path>> family2Files) throws IOException- Throws:
IOException
-
generateHFiles
- Throws:
IOException
-
waitForReplication
-
verifyBackup
private void verifyBackup(String backupRootDir, boolean hasBulkLoadFiles, Map<org.apache.hadoop.hbase.TableName, Integer> tablesWithExpectedRows) throws IOExceptionVerifies the backup process by: 1. Checking whether any WAL (Write-Ahead Log) files were generated in the backup directory. 2. Checking whether any bulk-loaded files were generated in the backup directory. 3. Replaying the WAL and bulk-loaded files (if present) to restore data and check consistency by verifying that the restored data matches the expected row count for each table.- Throws:
IOException
-
verifyWALBackup
- Throws:
IOException
-
verifyBulkLoadBackup
- Throws:
IOException
-
replayWALs
-
replayBulkLoadHFilesIfPresent
private void replayBulkLoadHFilesIfPresent(String bulkLoadDir, org.apache.hadoop.hbase.TableName tableName) -
getRowCount
- Throws:
IOException
-