Package org.apache.hadoop.hbase.wal
Class AbstractFSWALProvider<T extends AbstractFSWAL<?>>
java.lang.Object
org.apache.hadoop.hbase.wal.AbstractWALProvider
org.apache.hadoop.hbase.wal.AbstractFSWALProvider<T>
- All Implemented Interfaces:
 PeerActionListener,WALProvider
- Direct Known Subclasses:
 AsyncFSWALProvider,FSHLogProvider
@Private
@Evolving
public abstract class AbstractFSWALProvider<T extends AbstractFSWAL<?>>
extends AbstractWALProvider
Base class of a WAL Provider that returns a single thread safe WAL that writes to Hadoop FS. By
 default, this implementation picks a directory in Hadoop FS based on a combination of
 
- the HBase root directory
 - HConstants.HREGION_LOGDIR_NAME
 - the given factory's factoryId (usually identifying the regionserver by host:port)
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classComparator used to compare WAL files together based on their start time.Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.wal.WALProvider
WALProvider.AsyncWriter, WALProvider.Writer, WALProvider.WriterBase - 
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final Stringstatic final booleanprivate static final org.slf4j.Loggerstatic final StringThe hbase:meta region's WAL filename extensionprivate static final longDefine for when no timestamp found.static final StringSeparate old log into different dir by regionserver nameprivate static final Patternstatic final StringFile Extension used while splitting an WAL into regions (HBASE-2312)static final Comparator<org.apache.hadoop.fs.Path>protected Tstatic final Stringprivate static final PatternPattern used to validate a WAL file name seevalidateWALFilename(String)for description.private final ReadWriteLockWe use walCreateLock to prevent wal recreation in different threads, and also prevent getWALs missing the newly created WAL, see HBASE-21503 for more details.Fields inherited from class org.apache.hadoop.hbase.wal.AbstractWALProvider
abortable, conf, factory, initialized, listeners, logPrefix, providerIdFields inherited from interface org.apache.hadoop.hbase.replication.regionserver.PeerActionListener
DUMMY - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddWALActionsListener(WALActionsListener listener) Add aWALActionsListener.protected voidclose0()protected WALcreateRemoteWAL(RegionInfo region, org.apache.hadoop.fs.FileSystem remoteFs, org.apache.hadoop.fs.Path remoteWALDir, String prefix, String suffix) protected abstract Tprotected abstract voiddoInit(org.apache.hadoop.conf.Configuration conf) protected voiddoInit(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId) static longextractFileNumFromWAL(WAL wal) It returns the file create timestamp (the 'FileNum') from the file name.static org.apache.hadoop.fs.PathfindArchivedLog(org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf) Find the archived WAL file path if it is not able to locate in WALs dir.static List<org.apache.hadoop.fs.Path>getArchivedWALFiles(org.apache.hadoop.conf.Configuration conf, ServerName serverName, String logPrefix) List all the old wal files for a dead region server.static org.apache.hadoop.fs.PathgetCurrentFileName(WAL wal) return the current filename from the current wal.static longgetLogFileSize(WAL wal) returns the size of rolled WAL files.protected longiff the given WALFactory is using the DefaultWALProvider for meta and/or non-meta, count the size of files (only rolled).protected longiff the given WALFactory is using the DefaultWALProvider for meta and/or non-meta, count the number of files (rolled and active).static intgetNumRolledLogFiles(WAL wal) returns the number of rolled WAL files.static ServerNamegetServerNameFromWALDirectoryName(org.apache.hadoop.conf.Configuration conf, String path) Pulls a ServerName out of a Path generated according to our layout rules.static ServerNamegetServerNameFromWALDirectoryName(org.apache.hadoop.fs.Path logFile) This function returns region server name from a log file name which is in one of the following formats: hdfs://<name node>/hbase/.logs/<server name>-splitting/... hdfs://<name node>/hbase/.logs/<server name>/...static longgetTimestamp(String name) Split a WAL filename to get a start time.protected TgetWAL0(RegionInfo region) static StringgetWALArchiveDirectoryName(org.apache.hadoop.conf.Configuration conf, String serverName) Construct the directory name for all old WALs on a given server.static StringgetWALDirectoryName(String serverName) Construct the directory name for all WALs on a given server.static List<org.apache.hadoop.fs.Path>getWALFiles(org.apache.hadoop.conf.Configuration c, ServerName serverName) List all the wal files for a logPrefix.private static StringgetWALNameGroupFromWALName(String name, int group) static StringGet prefix of the log from its name, assuming WAL name in format of log_prefix.filenumber.log_suffixgetWALs0()static booleanisArchivedLogFile(org.apache.hadoop.fs.Path p) static booleanisMetaFile(String p) Returns True if String ends inMETA_WAL_PROVIDER_IDstatic booleanisMetaFile(org.apache.hadoop.fs.Path p) static ServerNameParse the server name from wal prefix.static voidrecoverLease(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path path) (package private) static voidrequestLogRoll(WAL wal) request a log roll, but don't actually do it.protected voidstatic booleanvalidateWALFilename(String filename) A WAL file name is of the format: <wal-name>WAL_FILE_NAME_DELIMITER<file-creation-timestamp>[.<suffix>].Methods inherited from class org.apache.hadoop.hbase.wal.AbstractWALProvider
close, getLogFileSize, getNumLogFiles, getPeerActionListener, getSyncReplicationPeerIdFromWALName, getWAL, getWALs, init, initWAL, peerSyncReplicationStateChange, setSyncReplicationPeerInfoProvider, shutdownMethods 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
 - 
SEPARATE_OLDLOGDIR
Separate old log into different dir by regionserver name- See Also:
 
 - 
DEFAULT_SEPARATE_OLDLOGDIR
- See Also:
 
 - 
wal
 - 
walCreateLock
We use walCreateLock to prevent wal recreation in different threads, and also prevent getWALs missing the newly created WAL, see HBASE-21503 for more details. - 
WAL_FILE_NAME_DELIMITER
- See Also:
 
 - 
META_WAL_PROVIDER_ID
The hbase:meta region's WAL filename extension- See Also:
 
 - 
DEFAULT_PROVIDER_ID
- See Also:
 
 - 
SPLITTING_EXT
File Extension used while splitting an WAL into regions (HBASE-2312)- See Also:
 
 - 
WAL_FILE_NAME_PATTERN
Pattern used to validate a WAL file name seevalidateWALFilename(String)for description. - 
NO_TIMESTAMP
Define for when no timestamp found.- See Also:
 
 - 
TIMESTAMP_COMPARATOR
 - 
SERVER_NAME_PATTERN
 
 - 
 - 
Constructor Details
- 
AbstractFSWALProvider
public AbstractFSWALProvider() 
 - 
 - 
Method Details
- 
doInit
protected void doInit(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId) throws IOException - Specified by:
 doInitin classAbstractWALProvider- Parameters:
 factory- factory that made us, identity used for FS layout. may not be nullconf- may not be nullproviderId- differentiate between providers from one factory, used for FS layout. may be null- Throws:
 IOException
 - 
getWALs0
- Specified by:
 getWALs0in classAbstractWALProvider
 - 
getWAL0
- Specified by:
 getWAL0in classAbstractWALProvider- Throws:
 IOException
 - 
createWAL
- Throws:
 IOException
 - 
doInit
- Throws:
 IOException
 - 
shutdown0
- Specified by:
 shutdown0in classAbstractWALProvider- Throws:
 IOException
 - 
close0
- Specified by:
 close0in classAbstractWALProvider- Throws:
 IOException
 - 
getNumLogFiles0
iff the given WALFactory is using the DefaultWALProvider for meta and/or non-meta, count the number of files (rolled and active). if either of them aren't, count 0 for that provider.- Specified by:
 getNumLogFiles0in classAbstractWALProvider
 - 
getLogFileSize0
iff the given WALFactory is using the DefaultWALProvider for meta and/or non-meta, count the size of files (only rolled). if either of them aren't, count 0 for that provider.- Specified by:
 getLogFileSize0in classAbstractWALProvider
 - 
createRemoteWAL
protected WAL createRemoteWAL(RegionInfo region, org.apache.hadoop.fs.FileSystem remoteFs, org.apache.hadoop.fs.Path remoteWALDir, String prefix, String suffix) throws IOException - Specified by:
 createRemoteWALin classAbstractWALProvider- Throws:
 IOException
 - 
getNumRolledLogFiles
returns the number of rolled WAL files. - 
getLogFileSize
returns the size of rolled WAL files. - 
getCurrentFileName
return the current filename from the current wal. - 
requestLogRoll
request a log roll, but don't actually do it. - 
extractFileNumFromWAL
It returns the file create timestamp (the 'FileNum') from the file name. For name format seevalidateWALFilename(String)public until remaining tests move to o.a.h.h.wal- Parameters:
 wal- must not be null- Returns:
 - the file number that is part of the WAL file name
 
 - 
validateWALFilename
A WAL file name is of the format: <wal-name>WAL_FILE_NAME_DELIMITER<file-creation-timestamp>[.<suffix>]. provider-name is usually made up of a server-name and a provider-id- Parameters:
 filename- name of the file to validate- Returns:
 - true if the filename matches an WAL, false otherwise
 
 - 
getTimestamp
Split a WAL filename to get a start time. WALs usually have the time we start writing to them with as part of their name, usually the suffix. Sometimes there will be an extra suffix as when it is a WAL for the meta table. For example, WALs might look like this10.20.20.171%3A60020.1277499063250where1277499063250is the timestamp. Could also be a meta WAL which adds a '.meta' suffix or a synchronous replication WAL which adds a '.syncrep' suffix. Check for these. File also may have no timestamp on it. For example the recovered.edits files are WALs but are named in ascending order. Here is an example: 0000000000000016310. Allow for this.- Parameters:
 name- Name of the WAL file.- Returns:
 - Timestamp or 
NO_TIMESTAMP. 
 - 
getWALDirectoryName
Construct the directory name for all WALs on a given server. Dir names currently look like this for WALs:hbase//WALs/kalashnikov.att.net,61634,1486865297088.- Parameters:
 serverName- Server name formatted as described inServerName- Returns:
 - the relative WAL directory name, e.g. 
.logs/1.example.org,60030,12345ifserverNamepassed is1.example.org,60030,12345 
 - 
getWALArchiveDirectoryName
public static String getWALArchiveDirectoryName(org.apache.hadoop.conf.Configuration conf, String serverName) Construct the directory name for all old WALs on a given server. The default old WALs dir looks like:hbase/oldWALs. If you config hbase.separate.oldlogdir.by.regionserver to true, it looks likehbase//oldWALs/kalashnikov.att.net,61634,1486865297088.- Parameters:
 serverName- Server name formatted as described inServerName- Returns:
 - the relative WAL directory name
 
 - 
getArchivedWALFiles
public static List<org.apache.hadoop.fs.Path> getArchivedWALFiles(org.apache.hadoop.conf.Configuration conf, ServerName serverName, String logPrefix) throws IOException List all the old wal files for a dead region server. Initially added for supporting replication, where we need to get the wal files to replicate for a dead region server.- Throws:
 IOException
 - 
getWALFiles
public static List<org.apache.hadoop.fs.Path> getWALFiles(org.apache.hadoop.conf.Configuration c, ServerName serverName) throws IOException List all the wal files for a logPrefix.- Throws:
 IOException
 - 
getServerNameFromWALDirectoryName
public static ServerName getServerNameFromWALDirectoryName(org.apache.hadoop.conf.Configuration conf, String path) throws IOException Pulls a ServerName out of a Path generated according to our layout rules. In the below layouts, this method ignores the format of the logfile component. Current format: [base directory for hbase]/hbase/.logs/ServerName/logfile or [base directory for hbase]/hbase/.logs/ServerName-splitting/logfile Expected to work for individual log files and server-specific directories.- Returns:
 - null if it's not a log file. Returns the ServerName of the region server that created this log file otherwise.
 - Throws:
 IOException
 - 
getServerNameFromWALDirectoryName
This function returns region server name from a log file name which is in one of the following formats:- hdfs://<name node>/hbase/.logs/<server name>-splitting/...
 - hdfs://<name node>/hbase/.logs/<server name>/...
 
- Returns:
 - null if the passed in logFile isn't a valid WAL file path
 
 - 
isMetaFile
 - 
isMetaFile
Returns True if String ends inMETA_WAL_PROVIDER_ID - 
isArchivedLogFile
 - 
findArchivedLog
public static org.apache.hadoop.fs.Path findArchivedLog(org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf) throws IOException Find the archived WAL file path if it is not able to locate in WALs dir.- Parameters:
 path- - active WAL file pathconf- - configuration- Returns:
 - archived path if exists, null - otherwise
 - Throws:
 IOException- exception
 - 
recoverLease
public static void recoverLease(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path path)  - 
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- Overrides:
 addWALActionsListenerin classAbstractWALProvider
 - 
getWALNameGroupFromWALName
 - 
getWALPrefixFromWALName
Get prefix of the log from its name, assuming WAL name in format of log_prefix.filenumber.log_suffix- Parameters:
 name- Name of the WAL to parse- Returns:
 - prefix of the log
 - Throws:
 IllegalArgumentException- if the name passed in is not a valid wal file name- See Also:
 
 - 
parseServerNameFromWALName
Parse the server name from wal prefix. A wal's name is always started with a server name in non test code.- Returns:
 - the server name
 - Throws:
 IllegalArgumentException- if the name passed in is not started with a server name
 
 -