Class FSReplicationPeerStorage
java.lang.Object
org.apache.hadoop.hbase.replication.FSReplicationPeerStorage
- All Implemented Interfaces:
ReplicationPeerStorage
A filesystem based replication peer storage. The implementation does not require atomic rename so
you can use it on cloud OSS.
FileSystem layout:
hbase | --peers | --<peer_id> | --peer_config | --disabled | --sync-rep-stateNotice that, if the peer is enabled, we will not have a disabled file. And for other files, to avoid depending on atomic rename, we will use two files for storing the content. When loading, we will try to read both the files and load the newer one. And when writing, we will write to the older file.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.apache.hadoop.fs.Path
(package private) static final String
private final org.apache.hadoop.fs.FileSystem
private static final org.slf4j.Logger
private static final long
(package private) static final String
static final String
static final String
-
Constructor Summary
ConstructorDescriptionFSReplicationPeerStorage
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPeer
(String peerId, ReplicationPeerConfig peerConfig, boolean enabled) Add a replication peer.private static void
getPeerConfig
(String peerId) Get the peer config of a replication peer.(package private) org.apache.hadoop.fs.Path
getPeerDir
(String peerId) boolean
isPeerEnabled
(String peerId) Test whether a replication peer is enabled.Return the peer ids of all replication peers.private static byte[]
void
removePeer
(String peerId) Remove a replication peer.void
setPeerState
(String peerId, boolean enabled) Set the state of peer,true
toENABLED
, otherwise toDISABLED
.void
updatePeerConfig
(String peerId, ReplicationPeerConfig peerConfig) Update the config a replication peer.private static void
-
Field Details
-
LOG
-
PEERS_DIR
- See Also:
-
PEERS_DIR_DEFAULT
- See Also:
-
PEER_CONFIG_FILE
- See Also:
-
DISABLED_FILE
- See Also:
-
fs
-
dir
-
MAX_FILE_SIZE
- See Also:
-
-
Constructor Details
-
FSReplicationPeerStorage
public FSReplicationPeerStorage(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
-
Method Details
-
getPeerDir
-
addPeer
public void addPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled) throws ReplicationException Description copied from interface:ReplicationPeerStorage
Add a replication peer.- Specified by:
addPeer
in interfaceReplicationPeerStorage
- Throws:
ReplicationException
- if there are errors accessing the storage service.
-
removePeer
Description copied from interface:ReplicationPeerStorage
Remove a replication peer.- Specified by:
removePeer
in interfaceReplicationPeerStorage
- Throws:
ReplicationException
- if there are errors accessing the storage service.
-
setPeerState
Description copied from interface:ReplicationPeerStorage
Set the state of peer,true
toENABLED
, otherwise toDISABLED
.- Specified by:
setPeerState
in interfaceReplicationPeerStorage
- Throws:
ReplicationException
- if there are errors accessing the storage service.
-
updatePeerConfig
public void updatePeerConfig(String peerId, ReplicationPeerConfig peerConfig) throws ReplicationException Description copied from interface:ReplicationPeerStorage
Update the config a replication peer.- Specified by:
updatePeerConfig
in interfaceReplicationPeerStorage
- Throws:
ReplicationException
- if there are errors accessing the storage service.
-
listPeerIds
Description copied from interface:ReplicationPeerStorage
Return the peer ids of all replication peers.- Specified by:
listPeerIds
in interfaceReplicationPeerStorage
- Throws:
ReplicationException
- if there are errors accessing the storage service.
-
isPeerEnabled
Description copied from interface:ReplicationPeerStorage
Test whether a replication peer is enabled.- Specified by:
isPeerEnabled
in interfaceReplicationPeerStorage
- Throws:
ReplicationException
- if there are errors accessing the storage service.
-
getPeerConfig
Description copied from interface:ReplicationPeerStorage
Get the peer config of a replication peer.- Specified by:
getPeerConfig
in interfaceReplicationPeerStorage
- Throws:
ReplicationException
- if there are errors accessing the storage service.
-
read
private static byte[] read(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir, String name) throws IOException - Throws:
IOException
-
write
private static void write(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir, String name, byte[] data) throws IOException - Throws:
IOException
-
delete
private static void delete(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir, String name) throws IOException - Throws:
IOException
-