Class ReplicationPeerManager
java.lang.Object
org.apache.hadoop.hbase.master.replication.ReplicationPeerManager
- All Implemented Interfaces:
ConfigurationObserver
Manages and performs all replication admin operations.
Used to add/remove a replication peer.
Implement ConfigurationObserver mainly for recreating ReplicationPeerStorage, for
supporting migrating across different replication peer storages without restarting master.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interface(package private) static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap<SyncReplicationState,EnumSet<SyncReplicationState>> private final Stringprivate org.apache.hadoop.conf.Configurationprivate final org.apache.hadoop.fs.FileSystemprivate static final org.slf4j.Loggerprivate final ConcurrentMap<String,ReplicationPeerDescription> private ReplicationPeerStorageprivate final ReplicationQueueStorageprivate final ZKWatcher -
Constructor Summary
ConstructorsConstructorDescriptionReplicationPeerManager(org.apache.hadoop.fs.FileSystem fs, ZKWatcher zk, ReplicationPeerStorage peerStorage, ReplicationQueueStorage queueStorage, ConcurrentMap<String, ReplicationPeerDescription> peers, org.apache.hadoop.conf.Configuration conf, String clusterId, ReplicationPeerManager.ReplicationQueueStorageInitializer queueStorageInitializer) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled) private voidcheckClusterKey(String clusterKey, ReplicationEndpoint endpoint) private voidcheckConfiguredWALEntryFilters(ReplicationPeerConfig peerConfig) private voidcheckNamespacesAndTableCfsConfigConflict(Set<String> namespaces, Map<TableName, ? extends Collection<String>> tableCfs) Set a namespace in the peer config means that all tables in this namespace will be replicated to the peer cluster.private voidcheckPeerConfig(ReplicationPeerConfig peerConfig) private voidprivate ReplicationPeerDescriptioncheckPeerExists(String peerId) private voidprivate voidcheckQueuesDeleted(String peerId) private voidprivate ReplicationQueueDatastatic ReplicationPeerManagercreate(MasterServices services, String clusterId) private static Pair<ReplicationQueueStorage,ReplicationPeerManager.ReplicationQueueStorageInitializer> createReplicationQueueStorage(MasterServices services) (package private) voidvoiddisablePeer(String peerId) voidenablePeer(String peerId) getPeerConfig(String peerId) booleangetPeerState(String peerId) getSerialPeerIdsBelongsTo(TableName tableName) (package private) booleanprivate voidprivate booleanisStringEquals(String s1, String s2) For replication peer cluster key or endpoint class, null and empty string is same.private voidmigrateHFileRefs(ZKReplicationQueueStorageForMigration oldQueueStorage) private voidmigrateLastPushedSeqIds(ZKReplicationQueueStorageForMigration oldQueueStorage) private voidmigrateQueues(ZKReplicationQueueStorageForMigration oldQueueStorage) (package private) CompletableFuture<Void>migrateQueuesFromZk(ZKWatcher zookeeper, ExecutorService executor) Submit the migration tasks to the givenexecutor.voidonConfigurationChange(org.apache.hadoop.conf.Configuration conf) This method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.(package private) voidpreAddPeer(String peerId, ReplicationPeerConfig peerConfig) (package private) voidpreDisablePeer(String peerId) (package private) voidpreEnablePeer(String peerId) (package private) ReplicationPeerConfigpreRemovePeer(String peerId) (package private) ReplicationPeerDescriptionpreTransitPeerSyncReplicationState(String peerId, SyncReplicationState state) Returns the old desciption of the peer(package private) ReplicationPeerDescriptionpreUpdatePeerConfig(String peerId, ReplicationPeerConfig peerConfig) Return the old peer description.(package private) voidremoveAllLastPushedSeqIds(String peerId) voidremoveAllQueues(String peerId) voidremoveAllQueuesAndHFileRefs(String peerId) voidremovePeer(String peerId) private CompletableFuture<?>runAsync(ReplicationPeerManager.ExceptionalRunnable task, ExecutorService executor) voidsetPeerNewSyncReplicationState(String peerId, SyncReplicationState state) private voidsetPeerState(String peerId, boolean enabled) voidtransitPeerSyncReplicationState(String peerId, SyncReplicationState newState) voidupdatePeerConfig(String peerId, ReplicationPeerConfig peerConfig)
-
Field Details
-
LOG
-
peerStorage
-
queueStorage
-
peers
-
allowedTransition
private final org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap<SyncReplicationState,EnumSet<SyncReplicationState>> allowedTransition -
clusterId
-
conf
-
fs
-
zk
-
queueStorageInitializer
-
-
Constructor Details
-
ReplicationPeerManager
ReplicationPeerManager(org.apache.hadoop.fs.FileSystem fs, ZKWatcher zk, ReplicationPeerStorage peerStorage, ReplicationQueueStorage queueStorage, ConcurrentMap<String, ReplicationPeerDescription> peers, org.apache.hadoop.conf.Configuration conf, String clusterId, ReplicationPeerManager.ReplicationQueueStorageInitializer queueStorageInitializer)
-
-
Method Details
-
checkQueuesDeleted
-
initializeQueueStorage
- Throws:
IOException
-
preAddPeer
void preAddPeer(String peerId, ReplicationPeerConfig peerConfig) throws ReplicationException, IOException - Throws:
ReplicationExceptionIOException
-
checkPeerExists
- Throws:
DoNotRetryIOException
-
checkPeerInDAStateIfSyncReplication
- Throws:
DoNotRetryIOException
-
preRemovePeer
- Throws:
DoNotRetryIOException
-
preEnablePeer
- Throws:
DoNotRetryIOException
-
preDisablePeer
- Throws:
DoNotRetryIOException
-
preUpdatePeerConfig
ReplicationPeerDescription preUpdatePeerConfig(String peerId, ReplicationPeerConfig peerConfig) throws DoNotRetryIOException Return the old peer description. Can never be null.- Throws:
DoNotRetryIOException
-
preTransitPeerSyncReplicationState
ReplicationPeerDescription preTransitPeerSyncReplicationState(String peerId, SyncReplicationState state) throws DoNotRetryIOException Returns the old desciption of the peer- Throws:
DoNotRetryIOException
-
addPeer
public void addPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled) throws ReplicationException - Throws:
ReplicationException
-
removePeer
- Throws:
ReplicationException
-
setPeerState
- Throws:
ReplicationException
-
getPeerState
- Throws:
ReplicationException
-
enablePeer
- Throws:
ReplicationException
-
disablePeer
- Throws:
ReplicationException
-
updatePeerConfig
public void updatePeerConfig(String peerId, ReplicationPeerConfig peerConfig) throws ReplicationException - Throws:
ReplicationException
-
listPeers
-
getPeerConfig
-
removeAllLastPushedSeqIds
- Throws:
ReplicationException
-
setPeerNewSyncReplicationState
public void setPeerNewSyncReplicationState(String peerId, SyncReplicationState state) throws ReplicationException - Throws:
ReplicationException
-
transitPeerSyncReplicationState
public void transitPeerSyncReplicationState(String peerId, SyncReplicationState newState) throws ReplicationException - Throws:
ReplicationException
-
removeAllQueues
- Throws:
ReplicationException
-
removeAllQueuesAndHFileRefs
- Throws:
ReplicationException
-
checkClusterKey
private void checkClusterKey(String clusterKey, ReplicationEndpoint endpoint) throws DoNotRetryIOException - Throws:
DoNotRetryIOException
-
checkPeerConfig
- Throws:
DoNotRetryIOException
-
checkPeerConfigForSyncReplication
private void checkPeerConfigForSyncReplication(ReplicationPeerConfig peerConfig) throws DoNotRetryIOException - Throws:
DoNotRetryIOException
-
checkSyncReplicationPeerConfigConflict
private void checkSyncReplicationPeerConfigConflict(ReplicationPeerConfig peerConfig) throws DoNotRetryIOException - Throws:
DoNotRetryIOException
-
checkNamespacesAndTableCfsConfigConflict
private void checkNamespacesAndTableCfsConfigConflict(Set<String> namespaces, Map<TableName, ? extends Collection<String>> tableCfs) throws DoNotRetryIOExceptionSet a namespace in the peer config means that all tables in this namespace will be replicated to the peer cluster.- If peer config already has a namespace, then not allow set any table of this namespace to the peer config.
- If peer config already has a table, then not allow set this table's namespace to the peer config.
Set a exclude namespace in the peer config means that all tables in this namespace can't be replicated to the peer cluster.
- If peer config already has a exclude namespace, then not allow set any exclude table of this namespace to the peer config.
- If peer config already has a exclude table, then not allow set this table's namespace as a exclude namespace.
- Throws:
DoNotRetryIOException
-
checkConfiguredWALEntryFilters
private void checkConfiguredWALEntryFilters(ReplicationPeerConfig peerConfig) throws DoNotRetryIOException - Throws:
DoNotRetryIOException
-
getSerialPeerIdsBelongsTo
-
getPeerStorage
-
getQueueStorage
-
createReplicationQueueStorage
private static Pair<ReplicationQueueStorage,ReplicationPeerManager.ReplicationQueueStorageInitializer> createReplicationQueueStorage(MasterServices services) throws IOException - Throws:
IOException
-
create
public static ReplicationPeerManager create(MasterServices services, String clusterId) throws ReplicationException, IOException - Throws:
ReplicationExceptionIOException
-
isStringEquals
For replication peer cluster key or endpoint class, null and empty string is same. So here don't useStringUtils.equals(CharSequence, CharSequence)directly. -
onConfigurationChange
Description copied from interface:ConfigurationObserverThis method would be called by theConfigurationManagerobject when theConfigurationobject is reloaded from disk.- Specified by:
onConfigurationChangein interfaceConfigurationObserver
-
convert
-
migrateQueues
- Throws:
Exception
-
migrateLastPushedSeqIds
private void migrateLastPushedSeqIds(ZKReplicationQueueStorageForMigration oldQueueStorage) throws Exception - Throws:
Exception
-
migrateHFileRefs
private void migrateHFileRefs(ZKReplicationQueueStorageForMigration oldQueueStorage) throws Exception - Throws:
Exception
-
runAsync
private CompletableFuture<?> runAsync(ReplicationPeerManager.ExceptionalRunnable task, ExecutorService executor) -
hasRegionReplicaReplicationPeer
- Throws:
ReplicationException
-
migrateQueuesFromZk
Submit the migration tasks to the givenexecutor. -
deleteLegacyRegionReplicaReplicationPeer
- Throws:
ReplicationException
-