@InterfaceAudience.Private public class SyncReplicationWALProvider extends Object implements WALProvider, PeerActionListener
WALProvider
for synchronous replication.
It works like an interceptor, when getting WAL, first it will check if the given region should be
replicated synchronously, if so it will return a special WAL for it, otherwise it will delegate
the request to the normal WALProvider
.
Modifier and Type | Class and Description |
---|---|
private static class |
SyncReplicationWALProvider.DefaultSyncReplicationPeerInfoProvider |
WALProvider.AsyncWriter, WALProvider.Writer, WALProvider.WriterBase
Modifier and Type | Field and Description |
---|---|
private Class<? extends org.apache.hbase.thirdparty.io.netty.channel.Channel> |
channelClass |
private org.apache.hadoop.conf.Configuration |
conf |
private KeyLocker<String> |
createLock |
static String |
DUAL_WAL_IMPL |
private org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup |
eventLoopGroup |
private WALFactory |
factory |
private AtomicBoolean |
initialized |
private List<WALActionsListener> |
listeners |
private static org.slf4j.Logger |
LOG |
private static Pattern |
LOG_PREFIX_PATTERN |
private ConcurrentMap<String,Optional<DualAsyncFSWAL>> |
peerId2WAL |
private SyncReplicationPeerInfoProvider |
peerInfoProvider |
private WALProvider |
provider |
DUMMY
Constructor and Description |
---|
SyncReplicationWALProvider(WALProvider provider) |
Modifier and Type | Method and Description |
---|---|
void |
addWALActionsListener(WALActionsListener listener)
Add a
WALActionsListener . |
void |
close()
shutdown utstanding WALs and clean up any persisted state.
|
private DualAsyncFSWAL |
createWAL(String peerId,
String remoteWALDir) |
long |
getLogFileSize()
Get size of the log files this provider is managing
|
private String |
getLogPrefix(String peerId) |
long |
getNumLogFiles()
Get number of the log files this provider is managing
|
static Optional<String> |
getSyncReplicationPeerIdFromWALName(String name)
Returns the peer id if the wal file name is in the special group for a sync replication peer.
|
WAL |
getWAL(RegionInfo region) |
private DualAsyncFSWAL |
getWAL(String peerId,
String remoteWALDir) |
List<WAL> |
getWALs() |
private Stream<WAL> |
getWALStream() |
(package private) WALProvider |
getWrappedProvider() |
void |
init(WALFactory factory,
org.apache.hadoop.conf.Configuration conf,
String providerId,
Abortable abortable)
Set up the provider to create wals.
|
void |
peerSyncReplicationStateChange(String peerId,
SyncReplicationState from,
SyncReplicationState to,
int stage) |
private void |
safeClose(WAL wal) |
void |
setPeerInfoProvider(SyncReplicationPeerInfoProvider peerInfoProvider) |
void |
shutdown()
persist outstanding WALs to storage and stop accepting new appends.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getWALFileLengthProvider
private static final org.slf4j.Logger LOG
public static final String DUAL_WAL_IMPL
private final WALProvider provider
private SyncReplicationPeerInfoProvider peerInfoProvider
private WALFactory factory
private org.apache.hadoop.conf.Configuration conf
private List<WALActionsListener> listeners
private org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup eventLoopGroup
private Class<? extends org.apache.hbase.thirdparty.io.netty.channel.Channel> channelClass
private AtomicBoolean initialized
private final ConcurrentMap<String,Optional<DualAsyncFSWAL>> peerId2WAL
private final KeyLocker<String> createLock
private static final Pattern LOG_PREFIX_PATTERN
SyncReplicationWALProvider(WALProvider provider)
public void setPeerInfoProvider(SyncReplicationPeerInfoProvider peerInfoProvider)
public void init(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId, Abortable abortable) throws IOException
WALProvider
init
in interface WALProvider
factory
- factory that made us may not be nullconf
- may not be nullproviderId
- differentiate between providers from one factory. may be nullIOException
private String getLogPrefix(String peerId)
private DualAsyncFSWAL createWAL(String peerId, String remoteWALDir) throws IOException
IOException
private DualAsyncFSWAL getWAL(String peerId, String remoteWALDir) throws IOException
IOException
public WAL getWAL(RegionInfo region) throws IOException
getWAL
in interface WALProvider
region
- the region which we want to get a WAL for it. Could be null.IOException
private Stream<WAL> getWALStream()
public List<WAL> getWALs()
getWALs
in interface WALProvider
public void shutdown() throws IOException
WALProvider
shutdown
in interface WALProvider
IOException
public void close() throws IOException
WALProvider
close
in interface WALProvider
IOException
public long getNumLogFiles()
WALProvider
getNumLogFiles
in interface WALProvider
public long getLogFileSize()
WALProvider
getLogFileSize
in interface WALProvider
public void addWALActionsListener(WALActionsListener listener)
WALProvider
WALActionsListener
.
Notice that you must call this method before calling WALProvider.getWAL(RegionInfo)
as this method
will not effect the WAL
which has already been created. And as long as we can only it
when initialization, it is not thread safe.
addWALActionsListener
in interface WALProvider
public void peerSyncReplicationStateChange(String peerId, SyncReplicationState from, SyncReplicationState to, int stage)
peerSyncReplicationStateChange
in interface PeerActionListener
public static Optional<String> getSyncReplicationPeerIdFromWALName(String name)
Returns the peer id if the wal file name is in the special group for a sync replication peer.
The prefix format is <factoryId>-<ts>-<peerId>.
WALProvider getWrappedProvider()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.