Package org.apache.hadoop.hbase.wal
Class AbstractWALProvider
java.lang.Object
org.apache.hadoop.hbase.wal.AbstractWALProvider
- All Implemented Interfaces:
PeerActionListener
,WALProvider
- Direct Known Subclasses:
AbstractFSWALProvider
,RegionGroupingProvider
@Private
public abstract class AbstractWALProvider
extends Object
implements WALProvider, PeerActionListener
Base class for a WAL Provider.
We will put some common logic here, especially for sync replication implementation, as it must do some hacks before the normal wal creation operation.
All WALProvider
implementations should extends this class instead of implement
WALProvider
directly, except DisabledWALProvider
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.wal.WALProvider
WALProvider.AsyncWriter, WALProvider.Writer, WALProvider.WriterBase
-
Field Summary
Modifier and TypeFieldDescriptionprotected Abortable
protected org.apache.hadoop.conf.Configuration
protected WALFactory
protected AtomicBoolean
protected List<WALActionsListener>
private static final org.slf4j.Logger
private static final Pattern
protected String
private final Condition
private int
private final Lock
private final ConcurrentMap<String,
Optional<WAL>> private SyncReplicationPeerInfoProvider
protected String
static final String
Fields inherited from interface org.apache.hadoop.hbase.replication.regionserver.PeerActionListener
DUMMY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addWALActionsListener
(WALActionsListener listener) Add aWALActionsListener
.private void
cleanup
(IOExceptionConsumer<WAL> cleanupWAL, IOExceptionRunnable finalCleanup) final void
close()
shutdown utstanding WALs and clean up any persisted state.protected abstract void
close0()
protected abstract WAL
createRemoteWAL
(RegionInfo region, org.apache.hadoop.fs.FileSystem remoteFs, org.apache.hadoop.fs.Path remoteWALDir, String prefix, String suffix) protected abstract void
doInit
(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId) final long
Get size of the log files this provider is managingprotected abstract long
final long
Get number of the log files this provider is managingprotected abstract long
private WAL
getRemoteWAL
(RegionInfo region, String peerId, String remoteWALDir) private String
getRemoteWALPrefix
(String peerId) Returns the peer id if the wal file name is in the special group for a sync replication peer.final WAL
getWAL
(RegionInfo region) protected abstract WAL
getWAL0
(RegionInfo region) getWALs()
Returns the List of WALs that are used by this servergetWALs0()
final void
init
(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId, Abortable server) Set up the provider to create wals.protected final void
void
peerSyncReplicationStateChange
(String peerId, SyncReplicationState from, SyncReplicationState to, int stage) private Stream<AbstractFSWAL<?>>
private static void
void
final void
shutdown()
persist outstanding WALs to storage and stop accepting new appends.protected abstract void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.wal.WALProvider
getWALFileLengthProvider
-
Field Details
-
LOG
-
WAL_FILE_NAME_DELIMITER
- See Also:
-
factory
-
conf
-
listeners
-
providerId
-
initialized
-
logPrefix
-
abortable
-
peerId2WAL
-
createLock
-
numRemoteWALUnderCreationLock
-
noRemoteWALUnderCreationCond
-
numRemoteWALUnderCreation
-
peerInfoProvider
-
LOG_PREFIX_PATTERN
-
-
Constructor Details
-
AbstractWALProvider
public AbstractWALProvider()
-
-
Method Details
-
init
public final void init(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId, Abortable server) throws IOException Description copied from interface:WALProvider
Set up the provider to create wals. will only be called once per instance.- Specified by:
init
in interfaceWALProvider
- Parameters:
factory
- factory that made us may not be nullconf
- may not be nullproviderId
- differentiate between providers from one factory. may be null- Throws:
IOException
-
initWAL
- Throws:
IOException
-
getRemoteWALPrefix
-
getRemoteWAL
- Throws:
IOException
-
getWAL
- Specified by:
getWAL
in interfaceWALProvider
- Parameters:
region
- the region which we want to get a WAL for it. Could be null.- Returns:
- a WAL for writing entries for the given region.
- Throws:
IOException
-
getWALs
Description copied from interface:WALProvider
Returns the List of WALs that are used by this server- Specified by:
getWALs
in interfaceWALProvider
-
getPeerActionListener
- Specified by:
getPeerActionListener
in interfaceWALProvider
-
peerSyncReplicationStateChange
public void peerSyncReplicationStateChange(String peerId, SyncReplicationState from, SyncReplicationState to, int stage) - Specified by:
peerSyncReplicationStateChange
in interfacePeerActionListener
-
setSyncReplicationPeerInfoProvider
- Specified by:
setSyncReplicationPeerInfoProvider
in interfaceWALProvider
-
safeClose
-
addWALActionsListener
Description copied from interface:WALProvider
Add aWALActionsListener
.Notice that you must call this method before calling
WALProvider.getWAL(RegionInfo)
as this method will not effect theWAL
which has already been created. And as long as we can only it when initialization, it is not thread safe.- Specified by:
addWALActionsListener
in interfaceWALProvider
-
cleanup
private void cleanup(IOExceptionConsumer<WAL> cleanupWAL, IOExceptionRunnable finalCleanup) throws IOException - Throws:
IOException
-
shutdown
Description copied from interface:WALProvider
persist outstanding WALs to storage and stop accepting new appends. This method serves as shorthand for sending a sync to every WAL provided by a given implementation. Those WALs will also stop accepting new writes.- Specified by:
shutdown
in interfaceWALProvider
- Throws:
IOException
-
close
Description copied from interface:WALProvider
shutdown utstanding WALs and clean up any persisted state. Call this method only when you will not need to replay any of the edits to the WALs from this provider. After this call completes, the underlying resources should have been reclaimed.- Specified by:
close
in interfaceWALProvider
- Throws:
IOException
-
remoteWALStream
-
getNumLogFiles
Description copied from interface:WALProvider
Get number of the log files this provider is managing- Specified by:
getNumLogFiles
in interfaceWALProvider
-
getLogFileSize
Description copied from interface:WALProvider
Get size of the log files this provider is managing- Specified by:
getLogFileSize
in interfaceWALProvider
-
getSyncReplicationPeerIdFromWALName
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>.
-
createRemoteWAL
protected abstract WAL createRemoteWAL(RegionInfo region, org.apache.hadoop.fs.FileSystem remoteFs, org.apache.hadoop.fs.Path remoteWALDir, String prefix, String suffix) throws IOException - Throws:
IOException
-
doInit
protected abstract void doInit(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId) throws IOException - Throws:
IOException
-
getWAL0
- Throws:
IOException
-
getWALs0
-
shutdown0
- Throws:
IOException
-
close0
- Throws:
IOException
-
getNumLogFiles0
-
getLogFileSize0
-