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
FieldsModifier and TypeFieldDescriptionprotected Abortableprotected org.apache.hadoop.conf.Configurationprotected WALFactoryprotected AtomicBooleanprotected List<WALActionsListener>private static final org.slf4j.Loggerprivate static final Patternprotected Stringprivate final Conditionprivate intprivate final Lockprivate final ConcurrentMap<String,Optional<WAL>> private SyncReplicationPeerInfoProviderprotected Stringstatic final StringFields inherited from interface org.apache.hadoop.hbase.replication.regionserver.PeerActionListener
DUMMY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWALActionsListener(WALActionsListener listener) Add aWALActionsListener.private voidcleanup(IOExceptionConsumer<WAL> cleanupWAL, IOExceptionRunnable finalCleanup) final voidclose()shutdown utstanding WALs and clean up any persisted state.protected abstract voidclose0()protected abstract WALcreateRemoteWAL(RegionInfo region, org.apache.hadoop.fs.FileSystem remoteFs, org.apache.hadoop.fs.Path remoteWALDir, String prefix, String suffix) protected abstract voiddoInit(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId) final longGet size of the log files this provider is managingprotected abstract longfinal longGet number of the log files this provider is managingprotected abstract longprivate WALgetRemoteWAL(RegionInfo region, String peerId, String remoteWALDir) private StringgetRemoteWALPrefix(String peerId) Returns the peer id if the wal file name is in the special group for a sync replication peer.final WALgetWAL(RegionInfo region) protected abstract WALgetWAL0(RegionInfo region) getWALs()Returns the List of WALs that are used by this servergetWALs0()final voidinit(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId, Abortable server) Set up the provider to create wals.protected final voidvoidpeerSyncReplicationStateChange(String peerId, SyncReplicationState from, SyncReplicationState to, int stage) private Stream<AbstractFSWAL<?>>private static voidvoidfinal voidshutdown()persist outstanding WALs to storage and stop accepting new appends.protected abstract voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:WALProviderSet up the provider to create wals. will only be called once per instance.- Specified by:
initin 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:
getWALin 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:WALProviderReturns the List of WALs that are used by this server- Specified by:
getWALsin interfaceWALProvider
-
getPeerActionListener
- Specified by:
getPeerActionListenerin interfaceWALProvider
-
peerSyncReplicationStateChange
public void peerSyncReplicationStateChange(String peerId, SyncReplicationState from, SyncReplicationState to, int stage) - Specified by:
peerSyncReplicationStateChangein interfacePeerActionListener
-
setSyncReplicationPeerInfoProvider
- Specified by:
setSyncReplicationPeerInfoProviderin interfaceWALProvider
-
safeClose
-
addWALActionsListener
Description copied from interface:WALProviderAdd aWALActionsListener.Notice that you must call this method before calling
WALProvider.getWAL(RegionInfo)as this method will not effect theWALwhich has already been created. And as long as we can only it when initialization, it is not thread safe.- Specified by:
addWALActionsListenerin interfaceWALProvider
-
cleanup
private void cleanup(IOExceptionConsumer<WAL> cleanupWAL, IOExceptionRunnable finalCleanup) throws IOException - Throws:
IOException
-
shutdown
Description copied from interface:WALProviderpersist 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:
shutdownin interfaceWALProvider- Throws:
IOException
-
close
Description copied from interface:WALProvidershutdown 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:
closein interfaceWALProvider- Throws:
IOException
-
remoteWALStream
-
getNumLogFiles
Description copied from interface:WALProviderGet number of the log files this provider is managing- Specified by:
getNumLogFilesin interfaceWALProvider
-
getLogFileSize
Description copied from interface:WALProviderGet size of the log files this provider is managing- Specified by:
getLogFileSizein 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
-