Class ContinuousBackupReplicationEndpoint
java.lang.Object
org.apache.hbase.thirdparty.com.google.common.util.concurrent.AbstractService
org.apache.hadoop.hbase.replication.BaseReplicationEndpoint
org.apache.hadoop.hbase.backup.replication.ContinuousBackupReplicationEndpoint
- All Implemented Interfaces:
ReplicationEndpoint,ReplicationPeerConfigListener,org.apache.hbase.thirdparty.com.google.common.util.concurrent.Service
ContinuousBackupReplicationEndpoint is responsible for replicating WAL entries to a backup
storage. It organizes WAL entries by day and periodically flushes the data, ensuring that WAL
files do not exceed the configured size. The class includes mechanisms for handling the WAL
files, performing bulk load backups, and ensuring that the replication process is safe.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.replication.ReplicationEndpoint
ReplicationEndpoint.Context, ReplicationEndpoint.ReplicateContextNested classes/interfaces inherited from interface org.apache.hbase.thirdparty.com.google.common.util.concurrent.Service
org.apache.hbase.thirdparty.com.google.common.util.concurrent.Service.Listener, org.apache.hbase.thirdparty.com.google.common.util.concurrent.Service.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BackupFileSystemManagerprivate org.apache.hadoop.conf.Configurationstatic final Stringstatic final Stringprivate longprivate final ReentrantLockprivate static final org.slf4j.Loggerstatic final longprivate Stringprivate UUIDprivate ReplicationSourceInterfacestatic final Stringprivate final Map<Long,FSHLogProvider.Writer> Fields inherited from class org.apache.hadoop.hbase.replication.BaseReplicationEndpoint
ctx, REPLICATION_WALENTRYFILTER_CONFIG_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidbackupWalEntries(long day, List<WAL.Entry> walEntries) voidHook invoked before persisting replication offsets.private voidclose()(package private) static voidcopyWithCleanup(org.apache.hadoop.fs.FileSystem srcFS, org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.FileSystem dstFS, org.apache.hadoop.fs.Path dst, org.apache.hadoop.conf.Configuration conf) Copy a file with cleanup logic in case of failure.private FSHLogProvider.WritercreateWalWriter(long dayInMillis) protected voiddoStart()protected voiddoStop()private static org.apache.hadoop.fs.PathfindExistingPath(org.apache.hadoop.fs.FileSystem rootFs, org.apache.hadoop.fs.Path baseNamespaceDir, org.apache.hadoop.fs.Path hFileArchiveDir, org.apache.hadoop.fs.Path filePath) private voidprivate org.apache.hadoop.fs.PathgetBulkLoadFileStagingPath(org.apache.hadoop.fs.Path relativePathFromNamespace) Returns a UUID of the provided peer id.groupEntriesByDay(List<WAL.Entry> entries) voidinit(ReplicationEndpoint.Context context) Initialize the replication endpoint with the given context.private voidprivate voidbooleanreplicate(ReplicationEndpoint.ReplicateContext replicateContext) Replicate the given set of entries (in the context) to the other cluster.voidstart()Initiates service startup and returns immediately.voidstop()If the service is starting or running, this initiates service shutdown and returns immediately.private voidPersists the latest replicated WAL entry timestamp in the backup system table.(package private) voiduploadBulkLoadFiles(long dayInMillis, List<org.apache.hadoop.fs.Path> bulkLoadFiles) Methods inherited from class org.apache.hadoop.hbase.replication.BaseReplicationEndpoint
canReplicateToSameCluster, getNamespaceTableCfWALEntryFilter, getScopeWALEntryFilter, getWALEntryfilter, isStarting, peerConfigUpdatedMethods inherited from class org.apache.hbase.thirdparty.com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, doCancelStart, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.replication.ReplicationEndpoint
awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning
-
Field Details
-
LOG
-
CONF_PEER_UUID
- See Also:
-
CONF_BACKUP_ROOT_DIR
- See Also:
-
walWriters
-
lock
-
replicationSource
-
conf
-
backupFileSystemManager
-
peerUUID
-
peerId
-
latestWALEntryTimestamp
-
ONE_DAY_IN_MILLISECONDS
-
WAL_FILE_PREFIX
- See Also:
-
-
Constructor Details
-
ContinuousBackupReplicationEndpoint
public ContinuousBackupReplicationEndpoint()
-
-
Method Details
-
init
Description copied from interface:ReplicationEndpointInitialize the replication endpoint with the given context.- Specified by:
initin interfaceReplicationEndpoint- Overrides:
initin classBaseReplicationEndpoint- Parameters:
context- replication context- Throws:
IOException- error occur when initialize the endpoint.
-
initializePeerUUID
- Throws:
IOException
-
initializeBackupFileSystemManager
- Throws:
IOException
-
flushWriters
- Throws:
IOException
-
getPeerUUID
Description copied from interface:ReplicationEndpointReturns a UUID of the provided peer id. Every HBase cluster instance has a persisted associated UUID. If the replication is not performed to an actual HBase cluster (but some other system), the UUID returned has to uniquely identify the connected target system.- Returns:
- a UUID or null if the peer cluster does not exist or is not connected.
-
start
Description copied from interface:ReplicationEndpointInitiates service startup and returns immediately. A stopped service may not be restarted. Equivalent of startAsync call in Guava Service. -
doStart
- Specified by:
doStartin classorg.apache.hbase.thirdparty.com.google.common.util.concurrent.AbstractService
-
replicate
Description copied from interface:ReplicationEndpointReplicate the given set of entries (in the context) to the other cluster. Can block until all the given entries are replicated. Upon this method is returned, all entries that were passed in the context are assumed to be persisted in the target cluster.- Parameters:
replicateContext- a context where WAL entries and other parameters can be obtained.
-
updateLastReplicatedTimestampForContinuousBackup
Persists the latest replicated WAL entry timestamp in the backup system table. This checkpoint is critical for Continuous Backup and Point-in-Time Restore (PITR) to ensure restore operations only go up to a known safe point. The value is stored per region server using its ServerName as the key.- Throws:
IOException- if the checkpoint update fails
-
groupEntriesByDay
-
backupWalEntries
- Throws:
IOException
-
createWalWriter
-
stop
Description copied from interface:ReplicationEndpointIf the service is starting or running, this initiates service shutdown and returns immediately. If the service has already been stopped, this method returns immediately without taking action. Equivalent of stopAsync call in Guava Service. -
doStop
- Specified by:
doStopin classorg.apache.hbase.thirdparty.com.google.common.util.concurrent.AbstractService
-
close
-
uploadBulkLoadFiles
void uploadBulkLoadFiles(long dayInMillis, List<org.apache.hadoop.fs.Path> bulkLoadFiles) throws BulkLoadUploadException - Throws:
BulkLoadUploadException
-
copyWithCleanup
static void copyWithCleanup(org.apache.hadoop.fs.FileSystem srcFS, org.apache.hadoop.fs.Path src, org.apache.hadoop.fs.FileSystem dstFS, org.apache.hadoop.fs.Path dst, org.apache.hadoop.conf.Configuration conf) throws IOException Copy a file with cleanup logic in case of failure. Always overwrite destination to avoid leaving corrupt partial files.- Throws:
IOException
-
getBulkLoadFileStagingPath
private org.apache.hadoop.fs.Path getBulkLoadFileStagingPath(org.apache.hadoop.fs.Path relativePathFromNamespace) throws IOException - Throws:
IOException
-
findExistingPath
private static org.apache.hadoop.fs.Path findExistingPath(org.apache.hadoop.fs.FileSystem rootFs, org.apache.hadoop.fs.Path baseNamespaceDir, org.apache.hadoop.fs.Path hFileArchiveDir, org.apache.hadoop.fs.Path filePath) throws IOException - Throws:
IOException
-
beforePersistingReplicationOffset
Description copied from interface:ReplicationEndpointHook invoked before persisting replication offsets. Eg: Buffered endpoints can flush/close WALs here.- Throws:
IOException
-