Class HBaseInterClusterReplicationEndpoint
java.lang.Object
org.apache.hbase.thirdparty.com.google.common.util.concurrent.AbstractService
org.apache.hadoop.hbase.replication.BaseReplicationEndpoint
org.apache.hadoop.hbase.replication.HBaseReplicationEndpoint
org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint
- All Implemented Interfaces:
Abortable,ReplicationEndpoint,ReplicationPeerConfigListener,org.apache.hbase.thirdparty.com.google.common.util.concurrent.Service
A
ReplicationEndpoint implementation for replicating
to another HBase cluster. For the slave cluster it selects a random number of peers using a
replication ratio. For example, if replication ration = 0.1 and slave cluster has 100 region
servers, 10 will be selected.
A stream is considered down when we cannot contact a region server on the peer cluster for more than 55 seconds by default.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.replication.HBaseReplicationEndpoint
HBaseReplicationEndpoint.SinkPeerNested 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 org.apache.hadoop.fs.Pathprivate booleanprivate booleanprivate org.apache.hadoop.fs.Pathprivate booleanprivate longprivate static final org.slf4j.Loggerprivate intprivate intprivate MetricsSourceprivate booleanstatic final StringDrop edits for CFs that been deleted from the replication source and targetstatic final StringDrop edits for tables that been deleted from the replication source and targetprivate booleanprivate Stringprivate intprivate longprivate intFields inherited from class org.apache.hadoop.hbase.replication.HBaseReplicationEndpoint
conf, DEFAULT_BAD_SINK_THRESHOLD, DEFAULT_REPLICATION_SOURCE_RATIOFields inherited from class org.apache.hadoop.hbase.replication.BaseReplicationEndpoint
ctx, REPLICATION_WALENTRYFILTER_CONFIG_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletableFuture<Integer>asyncReplicate(List<WAL.Entry> entries, int batchIndex, int timeout) Replicate entries to peer cluster by async API.private voidcreateBatches(List<WAL.Entry> entries) Divide the entries into multiple batches, so that we can replicate each batch in a thread pool concurrently.createParallelBatches(List<WAL.Entry> entries) createSerialBatches(List<WAL.Entry> entries) private voidfilterNotExistColumnFamilyEdits(List<List<WAL.Entry>> oldEntryList) filterNotExistTableEdits(List<List<WAL.Entry>> oldEntryList) private intvoidinit(ReplicationEndpoint.Context context) Initialize the replication endpoint with the given context.static booleanCheck if there's anNoSuchColumnFamilyExceptionin the caused by stacktrace.protected booleanstatic booleanCheck if there's anTableNotFoundExceptionin the caused by stacktrace.private Stringprivate voidonReplicateWALEntryException(int entriesHashCode, Throwable exception, HBaseReplicationEndpoint.SinkPeer sinkPeer) private longparallelReplicate(ReplicationEndpoint.ReplicateContext replicateContext, List<List<WAL.Entry>> batches) booleanreplicate(ReplicationEndpoint.ReplicateContext replicateContext) Do the shipping logicprotected CompletableFuture<Integer>replicateEntries(List<WAL.Entry> entries, int batchIndex, int timeout) private CompletableFuture<Integer>serialReplicateRegionEntries(org.apache.hbase.thirdparty.com.google.common.collect.PeekingIterator<WAL.Entry> walEntryPeekingIterator, int batchIndex, int timeout) Here forHBaseInterClusterReplicationEndpoint#isSerialisis true, we iterator over the WALWAL.Entrylist, once we reached a batch limit, we send it out, and in the callback, we send the next batch, until we send all entries out.private booleansleepForRetries(String msg, int sleepMultiplier) Do the sleeping logicMethods inherited from class org.apache.hadoop.hbase.replication.HBaseReplicationEndpoint
abort, chooseSinks, createConnection, doStart, doStop, fetchPeerAddresses, getNumSinks, getPeerUUID, getReplicationSink, isAborted, reportBadSink, reportSinkSuccess, start, stopMethods 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
-
REPLICATION_DROP_ON_DELETED_TABLE_KEY
Drop edits for tables that been deleted from the replication source and target- See Also:
-
REPLICATION_DROP_ON_DELETED_COLUMN_FAMILY_KEY
Drop edits for CFs that been deleted from the replication source and target- See Also:
-
sleepForRetries
-
maxRetriesMultiplier
-
socketTimeoutMultiplier
-
replicationRpcLimit
-
metrics
-
peersSelected
-
replicationClusterId
-
maxThreads
-
baseNamespaceDir
-
hfileArchiveDir
-
replicationBulkLoadDataEnabled
-
dropOnDeletedTables
-
dropOnDeletedColumnFamilies
-
isSerial
-
lastSinkFetchTime
-
-
Constructor Details
-
HBaseInterClusterReplicationEndpoint
public HBaseInterClusterReplicationEndpoint()
-
-
Method Details
-
init
Description copied from interface:ReplicationEndpointInitialize the replication endpoint with the given context.- Specified by:
initin interfaceReplicationEndpoint- Overrides:
initin classHBaseReplicationEndpoint- Parameters:
context- replication context- Throws:
IOException- error occur when initialize the endpoint.
-
decorateConf
-
connectToPeers
-
sleepForRetries
Do the sleeping logic- Parameters:
msg- Why we sleepsleepMultiplier- by how many times the default sleeping time is augmented- Returns:
- True if
sleepMultiplieris <maxRetriesMultiplier
-
getEstimatedEntrySize
-
createParallelBatches
-
createSerialBatches
-
createBatches
Divide the entries into multiple batches, so that we can replicate each batch in a thread pool concurrently. Note that, for serial replication, we need to make sure that entries from the same region to be replicated serially, so entries from the same region consist of a batch, and we will divide a batch into several batches by replicationRpcLimit in method serialReplicateRegionEntries() -
isTableNotFoundException
Check if there's anTableNotFoundExceptionin the caused by stacktrace. -
isNoSuchColumnFamilyException
Check if there's anNoSuchColumnFamilyExceptionin the caused by stacktrace. -
filterNotExistTableEdits
-
filterNotExistColumnFamilyEdits
-
parallelReplicate
private long parallelReplicate(ReplicationEndpoint.ReplicateContext replicateContext, List<List<WAL.Entry>> batches) throws IOException - Throws:
IOException
-
replicate
Do the shipping logic- Parameters:
replicateContext- a context where WAL entries and other parameters can be obtained.
-
isPeerEnabled
-
replicateEntries
protected CompletableFuture<Integer> replicateEntries(List<WAL.Entry> entries, int batchIndex, int timeout) -
onReplicateWALEntryException
private void onReplicateWALEntryException(int entriesHashCode, Throwable exception, HBaseReplicationEndpoint.SinkPeer sinkPeer) -
serialReplicateRegionEntries
private CompletableFuture<Integer> serialReplicateRegionEntries(org.apache.hbase.thirdparty.com.google.common.collect.PeekingIterator<WAL.Entry> walEntryPeekingIterator, int batchIndex, int timeout) Here forHBaseInterClusterReplicationEndpoint#isSerialisis true, we iterator over the WALWAL.Entrylist, once we reached a batch limit, we send it out, and in the callback, we send the next batch, until we send all entries out. -
asyncReplicate
protected CompletableFuture<Integer> asyncReplicate(List<WAL.Entry> entries, int batchIndex, int timeout) Replicate entries to peer cluster by async API. -
logPeerId
-