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.SinkPeer
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.replication.ReplicationEndpoint
ReplicationEndpoint.Context, ReplicationEndpoint.ReplicateContext
Nested 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
Modifier and TypeFieldDescriptionprivate org.apache.hadoop.fs.Path
private boolean
private boolean
private org.apache.hadoop.fs.Path
private boolean
private long
private static final org.slf4j.Logger
private int
private int
private MetricsSource
private boolean
static final String
Drop edits for CFs that been deleted from the replication source and targetstatic final String
Drop edits for tables that been deleted from the replication source and targetprivate boolean
private String
private int
private long
private int
Fields inherited from class org.apache.hadoop.hbase.replication.HBaseReplicationEndpoint
conf, DEFAULT_BAD_SINK_THRESHOLD, DEFAULT_REPLICATION_SOURCE_RATIO
Fields inherited from class org.apache.hadoop.hbase.replication.BaseReplicationEndpoint
ctx, REPLICATION_WALENTRYFILTER_CONFIG_KEY
-
Constructor Summary
-
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 void
createBatches
(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 void
filterNotExistColumnFamilyEdits
(List<List<WAL.Entry>> oldEntryList) filterNotExistTableEdits
(List<List<WAL.Entry>> oldEntryList) private int
void
init
(ReplicationEndpoint.Context context) Initialize the replication endpoint with the given context.static boolean
Check if there's anNoSuchColumnFamilyException
in the caused by stacktrace.protected boolean
static boolean
Check if there's anTableNotFoundException
in the caused by stacktrace.private String
private void
onReplicateWALEntryException
(int entriesHashCode, Throwable exception, HBaseReplicationEndpoint.SinkPeer sinkPeer) private long
parallelReplicate
(ReplicationEndpoint.ReplicateContext replicateContext, List<List<WAL.Entry>> batches) boolean
replicate
(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#isSerialis
is true, we iterator over the WALWAL.Entry
list, 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 boolean
sleepForRetries
(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, stop
Methods inherited from class org.apache.hadoop.hbase.replication.BaseReplicationEndpoint
canReplicateToSameCluster, getNamespaceTableCfWALEntryFilter, getScopeWALEntryFilter, getWALEntryfilter, isStarting, peerConfigUpdated
Methods 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:ReplicationEndpoint
Initialize the replication endpoint with the given context.- Specified by:
init
in interfaceReplicationEndpoint
- Overrides:
init
in 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
sleepMultiplier
is <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 anTableNotFoundException
in the caused by stacktrace. -
isNoSuchColumnFamilyException
Check if there's anNoSuchColumnFamilyException
in 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#isSerialis
is true, we iterator over the WALWAL.Entry
list, 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
-