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
Nested ClassesModifier and TypeClassDescription(package private) static enumMaps between configuration names for providers and implementation classes. - 
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Abortableprivate final org.apache.hadoop.conf.Configuration(package private) static final Stringprivate final ExcludeDatanodeManager(package private) final Stringprivate static final org.slf4j.Loggerstatic final Stringprivate final LazyInitializedWALProviderprivate final WALProviderstatic final String(package private) static final Stringprivate final LazyInitializedWALProviderprivate static final AtomicReference<WALFactory>private static final Stringprivate final intHow long to attempt opening in-recovery walsstatic final Stringstatic final Stringstatic final StringUsed 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
ConstructorsModifierConstructorDescriptionprivateWALFactory(org.apache.hadoop.conf.Configuration conf) WALFactory(org.apache.hadoop.conf.Configuration conf, String factoryId) Create a WALFactory.privateWALFactory(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 TypeMethodDescriptionvoidclose()Shutdown all WALs and clean up any underlying storage.(package private) static WALProvidercreateProvider(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.WritercreateRecoveredEditsWriter(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 WALStreamReadercreateStreamReader(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 WALStreamReadercreateStreamReader(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 WALTailingReadercreateTailingReader(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.WritercreateWALWriter(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.ConfigurationgetConf()(package private) WALFactory.Providersstatic WALFactorygetInstance(org.apache.hadoop.conf.Configuration configuration) (package private) WALProvider(package private) Class<? extends WALProvider>getProviderClass(String key, String defaultValue) (package private) WALProvidergetWAL(RegionInfo region) getWALs()voidshutdown()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 useSecureWALCellCodecto 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 thefactoryIdis 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
 
 -