@InterfaceAudience.Private @InterfaceStability.Evolving public abstract class AbstractFSWALProvider<T extends AbstractFSWAL<?>> extends Object implements WALProvider
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractFSWALProvider.Reader |
WALProvider.AsyncWriter, WALProvider.Writer, WALProvider.WriterBase
Modifier and Type | Field and Description |
---|---|
protected org.apache.hadoop.conf.Configuration |
conf |
static boolean |
DEFAULT_SEPARATE_OLDLOGDIR |
protected WALFactory |
factory |
protected AtomicBoolean |
initialized |
protected List<WALActionsListener> |
listeners |
protected String |
logPrefix |
static String |
META_WAL_PROVIDER_ID
The hbase:meta region's WAL filename extension
|
protected String |
providerId |
static String |
SEPARATE_OLDLOGDIR
Separate old log into different dir by regionserver name
|
static String |
SPLITTING_EXT
File Extension used while splitting an WAL into regions (HBASE-2312)
|
protected T |
wal |
static String |
WAL_FILE_NAME_DELIMITER |
Constructor and Description |
---|
AbstractFSWALProvider() |
Modifier and Type | Method and Description |
---|---|
void |
addWALActionsListener(WALActionsListener listener)
Add a
WALActionsListener . |
void |
close()
shutdown utstanding WALs and clean up any persisted state.
|
protected abstract T |
createWAL() |
protected abstract void |
doInit(org.apache.hadoop.conf.Configuration conf) |
static long |
extractFileNumFromWAL(WAL wal)
It returns the file create timestamp from the file name.
|
static org.apache.hadoop.fs.Path |
getArchivedLogPath(org.apache.hadoop.fs.Path path,
org.apache.hadoop.conf.Configuration conf)
Get the archived WAL file path
|
static org.apache.hadoop.fs.Path |
getCurrentFileName(WAL wal)
return the current filename from the current wal.
|
long |
getLogFileSize()
iff the given WALFactory is using the DefaultWALProvider for meta and/or non-meta, count the
size of files (only rolled).
|
static long |
getLogFileSize(WAL wal)
returns the size of rolled WAL files.
|
long |
getNumLogFiles()
iff the given WALFactory is using the DefaultWALProvider for meta and/or non-meta, count the
number of files (rolled and active).
|
static int |
getNumRolledLogFiles(WAL wal)
returns the number of rolled WAL files.
|
static ServerName |
getServerNameFromWALDirectoryName(org.apache.hadoop.conf.Configuration conf,
String path)
Pulls a ServerName out of a Path generated according to our layout rules.
|
static ServerName |
getServerNameFromWALDirectoryName(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>/...
|
T |
getWAL(RegionInfo region) |
static String |
getWALArchiveDirectoryName(org.apache.hadoop.conf.Configuration conf,
String serverName)
Construct the directory name for all old WALs on a given server.
|
static String |
getWALDirectoryName(String serverName)
Construct the directory name for all WALs on a given server.
|
static String |
getWALPrefixFromWALName(String name)
Get prefix of the log from its name, assuming WAL name in format of
log_prefix.filenumber.log_suffix
|
List<WAL> |
getWALs() |
void |
init(WALFactory factory,
org.apache.hadoop.conf.Configuration conf,
String providerId)
Set up the provider to create wals.
|
static boolean |
isArchivedLogFile(org.apache.hadoop.fs.Path p) |
static boolean |
isMetaFile(org.apache.hadoop.fs.Path p) |
static boolean |
isMetaFile(String p) |
static WAL.Reader |
openReader(org.apache.hadoop.fs.Path path,
org.apache.hadoop.conf.Configuration conf)
Opens WAL reader with retries and additional exception handling
|
void |
shutdown()
persist outstanding WALs to storage and stop accepting new appends.
|
static boolean |
validateWALFilename(String filename)
A WAL file name is of the format: <wal-name>
WAL_FILE_NAME_DELIMITER
<file-creation-timestamp>[.meta]. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getWALFileLengthProvider
public static final String SEPARATE_OLDLOGDIR
public static final boolean DEFAULT_SEPARATE_OLDLOGDIR
protected volatile T extends AbstractFSWAL<?> wal
protected WALFactory factory
protected org.apache.hadoop.conf.Configuration conf
protected List<WALActionsListener> listeners
protected String providerId
protected AtomicBoolean initialized
protected String logPrefix
public static final String WAL_FILE_NAME_DELIMITER
public static final String META_WAL_PROVIDER_ID
public static final String SPLITTING_EXT
public void init(WALFactory factory, org.apache.hadoop.conf.Configuration conf, String providerId) throws IOException
WALProvider
init
in interface WALProvider
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
nullIOException
public List<WAL> getWALs()
getWALs
in interface WALProvider
public T 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
protected abstract T createWAL() throws IOException
IOException
protected abstract void doInit(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
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()
getNumLogFiles
in interface WALProvider
public long getLogFileSize()
getLogFileSize
in interface WALProvider
public static int getNumRolledLogFiles(WAL wal)
public static long getLogFileSize(WAL wal)
public static org.apache.hadoop.fs.Path getCurrentFileName(WAL wal)
public static long extractFileNumFromWAL(WAL wal)
validateWALFilename(String)
public until remaining tests move to o.a.h.h.walwal
- must not be nullpublic static boolean validateWALFilename(String filename)
WAL_FILE_NAME_DELIMITER
<file-creation-timestamp>[.meta]. provider-name is usually made up of a server-name and a
provider-idfilename
- name of the file to validatepublic static String getWALDirectoryName(String serverName)
hbase//WALs/kalashnikov.att.net,61634,1486865297088
.serverName
- Server name formatted as described in ServerName
.logs/1.example.org,60030,12345
if
serverName
passed is 1.example.org,60030,12345
public static String getWALArchiveDirectoryName(org.apache.hadoop.conf.Configuration conf, String serverName)
hbase/oldWALs
. If you config hbase.separate.oldlogdir.by.regionserver to
true, it looks like hbase//oldWALs/kalashnikov.att.net,61634,1486865297088
.conf
- serverName
- Server name formatted as described in ServerName
public static ServerName getServerNameFromWALDirectoryName(org.apache.hadoop.conf.Configuration conf, String path) throws IOException
IOException
public static ServerName getServerNameFromWALDirectoryName(org.apache.hadoop.fs.Path logFile)
public static boolean isMetaFile(org.apache.hadoop.fs.Path p)
public static boolean isMetaFile(String p)
public static boolean isArchivedLogFile(org.apache.hadoop.fs.Path p)
public static org.apache.hadoop.fs.Path getArchivedLogPath(org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf) throws IOException
path
- - active WAL file pathconf
- - configurationIOException
- exceptionpublic static WAL.Reader openReader(org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf) throws IOException
path
- path to WAL fileconf
- configurationIOException
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 static String getWALPrefixFromWALName(String name)
name
- Name of the WAL to parseAbstractFSWAL.getCurrentFileName()
Copyright © 2007–2019 Cloudera. All rights reserved.