Package org.apache.hadoop.hbase.wal
Class WALFactory
java.lang.Object
org.apache.hadoop.hbase.wal.WALFactory
Entry point for users of the Write Ahead Log. Acts as the shim between internal use and the
particular WALProvider we use to handle wal requests. Configure which provider gets used with the
configuration setting "hbase.wal.provider". Available implementations:
- defaultProvider : whatever provider is standard for the hbase version. Currently "asyncfs"
- asyncfs : a provider that will run on top of an implementation of the Hadoop FileSystem interface via an asynchronous client.
- filesystem : a provider that will run on top of an implementation of the Hadoop FileSystem interface via HDFS's synchronous DFSClient.
- multiwal : a provider that will use multiple "filesystem" wal instances per region server.
WALProvider
by class name.-
Nested Class Summary
Modifier and TypeClassDescription(package private) static enum
Maps between configuration names for providers and implementation classes. -
Field Summary
Modifier and TypeFieldDescription(package private) final Abortable
private final org.apache.hadoop.conf.Configuration
(package private) static final String
private final ExcludeDatanodeManager
(package private) final String
private static final org.slf4j.Logger
static final String
private final LazyInitializedWALProvider
private final WALProvider
static final String
(package private) static final String
private final LazyInitializedWALProvider
private static final AtomicReference<WALFactory>
private static final String
private final int
How long to attempt opening in-recovery walsstatic final String
static final String
static final String
Used in tests for injecting customized stream reader implementation, for example, inject fault when reading, etc.private final Class<? extends WALStreamReader>
Configuration-specified WAL Reader used when a custom reader is requested -
Constructor Summary
ModifierConstructorDescriptionprivate
WALFactory
(org.apache.hadoop.conf.Configuration conf) WALFactory
(org.apache.hadoop.conf.Configuration conf, String factoryId) Create a WALFactory.private
WALFactory
(org.apache.hadoop.conf.Configuration conf, String factoryId, Abortable abortable) WALFactory
(org.apache.hadoop.conf.Configuration conf, ServerName serverName, Abortable abortable) Create a WALFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Shutdown all WALs and clean up any underlying storage.(package private) static WALProvider
createProvider
(Class<? extends WALProvider> clazz) createRecoveredEditsWriter
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) Should be package-private, visible for recovery testing.(package private) static WALProvider.Writer
createRecoveredEditsWriter
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration configuration) If you already have a WALFactory, you should favor the instance method.createStreamReader
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) static WALStreamReader
createStreamReader
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf) Create a one-way stream reader for a given path.static WALStreamReader
createStreamReader
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf, long startPosition) Create a one-way stream reader for a given path.createStreamReader
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, CancelableProgressable reporter) Create a one-way stream reader for the WAL.createStreamReader
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, CancelableProgressable reporter, long startPosition) Create a one-way stream reader for the WAL, and start reading from the givenstartPosition
.static WALTailingReader
createTailingReader
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf, long startPosition) Create a tailing reader for the given path.createWALWriter
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) Create a writer for the WAL.static WALProvider.Writer
createWALWriter
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration configuration) If you already have a WALFactory, you should favor the instance method.Returns all the wal providers, for example, the default one, the one for hbase:meta and the one for hbase:replication.org.apache.hadoop.conf.Configuration
getConf()
(package private) WALFactory.Providers
static WALFactory
getInstance
(org.apache.hadoop.conf.Configuration configuration) (package private) WALProvider
(package private) Class<? extends WALProvider>
getProviderClass
(String key, String defaultValue) (package private) WALProvider
getWAL
(RegionInfo region) getWALs()
void
shutdown()
Tell the underlying WAL providers to shut down, but do not clean up underlying storage.
-
Field Details
-
WAL_STREAM_READER_CLASS_IMPL
Used in tests for injecting customized stream reader implementation, for example, inject fault when reading, etc. After removing the sequence file based WAL, we always use protobuf based WAL reader, and we will also determine whether the WAL file is encrypted and we should useSecureWALCellCodec
to decode by check the header of the WAL file, so we do not need to specify a specical reader to read the WAL file either. So typically you should not use this config in production.- See Also:
-
LOG
-
WAL_PROVIDER
- See Also:
-
DEFAULT_WAL_PROVIDER
-
META_WAL_PROVIDER
- See Also:
-
REPLICATION_WAL_PROVIDER
- See Also:
-
WAL_ENABLED
- See Also:
-
REPLICATION_WAL_PROVIDER_ID
- See Also:
-
factoryId
-
abortable
-
provider
-
metaProvider
-
replicationProvider
-
walStreamReaderClass
Configuration-specified WAL Reader used when a custom reader is requested -
timeoutMillis
How long to attempt opening in-recovery wals -
conf
-
excludeDatanodeManager
-
singleton
-
SINGLETON_ID
-
-
Constructor Details
-
WALFactory
-
WALFactory
Create a WALFactory.- Throws:
IOException
-
WALFactory
public WALFactory(org.apache.hadoop.conf.Configuration conf, ServerName serverName, Abortable abortable) throws IOException Create a WALFactory. This is the constructor you should use when creating a WALFactory in normal code, to make sure that thefactoryId
is the server name. We need this assumption in some places for parsing the server name out from the wal file name.- Parameters:
conf
- must not be null, will keep a reference to read params in later reader/writer instances.serverName
- use to generate the factoryId, which will be append at the first of the final file nameabortable
- the server associated with this WAL file- Throws:
IOException
-
WALFactory
private WALFactory(org.apache.hadoop.conf.Configuration conf, String factoryId, Abortable abortable) throws IOException - Parameters:
conf
- must not be null, will keep a reference to read params in later reader/writer instances.factoryId
- a unique identifier for this factory. used i.e. by filesystem implementations to make a directoryabortable
- the server associated with this WAL file- Throws:
IOException
-
-
Method Details
-
getDefaultProvider
-
getProviderClass
-
createProvider
- Throws:
IOException
-
getConf
-
close
Shutdown all WALs and clean up any underlying storage. Use only when you will not need to replay and edits that have gone to any wals from this factory.- Throws:
IOException
-
shutdown
Tell the underlying WAL providers to shut down, but do not clean up underlying storage. If you are not ending cleanly and will need to replay edits from this factory's wals, use this method if you can as it will try to leave things as tidy as possible.- Throws:
IOException
-
getWALs
-
getMetaProvider
- Throws:
IOException
-
getReplicationProvider
- Throws:
IOException
-
getWAL
- Parameters:
region
- the region which we want to get a WAL for. Could be null.- Throws:
IOException
-
createStreamReader
public WALStreamReader createStreamReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException - Throws:
IOException
-
createStreamReader
public WALStreamReader createStreamReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, CancelableProgressable reporter) throws IOException Create a one-way stream reader for the WAL.- Returns:
- A WAL reader. Close when done with it.
- Throws:
IOException
-
createStreamReader
public WALStreamReader createStreamReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, CancelableProgressable reporter, long startPosition) throws IOException Create a one-way stream reader for the WAL, and start reading from the givenstartPosition
.- Returns:
- A WAL reader. Close when done with it.
- Throws:
IOException
-
createWALWriter
public WALProvider.Writer createWALWriter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException Create a writer for the WAL. Uses defaults.Should be package-private. public only for tests and
Compressor
- Returns:
- A WAL writer. Close when done with it.
- Throws:
IOException
-
createRecoveredEditsWriter
public WALProvider.Writer createRecoveredEditsWriter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException Should be package-private, visible for recovery testing. Uses defaults.- Returns:
- an overwritable writer for recovered edits. caller should close.
- Throws:
IOException
-
getInstance
-
createTailingReader
public static WALTailingReader createTailingReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf, long startPosition) throws IOException Create a tailing reader for the given path. Mainly used in replication.- Throws:
IOException
-
createStreamReader
public static WALStreamReader createStreamReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf) throws IOException Create a one-way stream reader for a given path.- Throws:
IOException
-
createStreamReader
public static WALStreamReader createStreamReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf, long startPosition) throws IOException Create a one-way stream reader for a given path.- Throws:
IOException
-
createRecoveredEditsWriter
static WALProvider.Writer createRecoveredEditsWriter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration configuration) throws IOException If you already have a WALFactory, you should favor the instance method. Uses defaults.- Returns:
- a Writer that will overwrite files. Caller must close.
- Throws:
IOException
-
createWALWriter
public static WALProvider.Writer createWALWriter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration configuration) throws IOException If you already have a WALFactory, you should favor the instance method. Uses defaults.- Returns:
- a writer that won't overwrite files. Caller must close.
- Throws:
IOException
-
getWALProvider
-
getAllWALProviders
Returns all the wal providers, for example, the default one, the one for hbase:meta and the one for hbase:replication. -
getExcludeDatanodeManager
-
getFactoryId
-