Class AsyncProtobufLogWriter
java.lang.Object
org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufLogWriter
org.apache.hadoop.hbase.regionserver.wal.AsyncProtobufLogWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,AsyncFSWALProvider.AsyncWriter
,WALProvider.AsyncWriter
,WALProvider.WriterBase
@Private
public class AsyncProtobufLogWriter
extends AbstractProtobufLogWriter
implements AsyncFSWALProvider.AsyncWriter
AsyncWriter for protobuf-based WAL.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate OutputStream
private final Class<? extends org.apache.hbase.thirdparty.io.netty.channel.Channel>
private final org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup
private long
SaveAsyncFSOutput.getSyncedLength()
whenoutput
is closed.private static final org.slf4j.Logger
private AsyncFSOutput
private long
Fields inherited from class org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufLogWriter
cellEncoder, compressionContext, compressor, conf, encryptor, length, trailer, trailerWarnSize, trailerWritten
-
Constructor Summary
ConstructorDescriptionAsyncProtobufLogWriter
(org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup eventLoopGroup, Class<? extends org.apache.hbase.thirdparty.io.netty.channel.Channel> channelClass) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
close()
protected void
It is straight forward to close the output, do not need to write trailer like the Writer.closeprotected OutputStream
long
NOTE: We add this method forWALFileLengthProvider
used for replication, considering the case if we useAsyncFSWAL
,we write to 3 DNs concurrently, according to the visibility guarantee of HDFS, the data will be available immediately when arriving at DN since all the DNs will be considered as the last one in pipeline.protected void
initOutput
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, boolean overwritable, int bufferSize, short replication, long blockSize, StreamSlowMonitor monitor, boolean noLocalWrite) sync
(boolean forceSync) protected long
writeMagicAndWALHeader
(byte[] magic, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALHeader header) return the file length after written.private long
writeWALMetadata
(Consumer<CompletableFuture<Long>> action) protected long
writeWALTrailerAndMagic
(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALTrailer trailer, byte[] magic) Methods inherited from class org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufLogWriter
getLength, init, setWALTrailer, writeWALTrailer
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.wal.AsyncFSWALProvider.AsyncWriter
init
Methods inherited from interface org.apache.hadoop.hbase.wal.WALProvider.WriterBase
getLength
-
Field Details
-
LOG
-
eventLoopGroup
-
channelClass
-
output
-
finalSyncedLength
SaveAsyncFSOutput.getSyncedLength()
whenoutput
is closed. -
asyncOutputWrapper
-
waitTimeout
-
-
Constructor Details
-
AsyncProtobufLogWriter
public AsyncProtobufLogWriter(org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup eventLoopGroup, Class<? extends org.apache.hbase.thirdparty.io.netty.channel.Channel> channelClass)
-
-
Method Details
-
append
- Specified by:
append
in interfaceWALProvider.AsyncWriter
-
sync
- Specified by:
sync
in interfaceWALProvider.AsyncWriter
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getOutput
-
initOutput
protected void initOutput(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, boolean overwritable, int bufferSize, short replication, long blockSize, StreamSlowMonitor monitor, boolean noLocalWrite) throws IOException, CommonFSUtils.StreamLacksCapabilityException - Specified by:
initOutput
in classAbstractProtobufLogWriter
- Throws:
IOException
CommonFSUtils.StreamLacksCapabilityException
-
closeOutputIfNecessary
Description copied from class:AbstractProtobufLogWriter
It is straight forward to close the output, do not need to write trailer like the Writer.close- Overrides:
closeOutputIfNecessary
in classAbstractProtobufLogWriter
-
writeWALMetadata
- Throws:
IOException
-
writeMagicAndWALHeader
protected long writeMagicAndWALHeader(byte[] magic, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALHeader header) throws IOException Description copied from class:AbstractProtobufLogWriter
return the file length after written.- Specified by:
writeMagicAndWALHeader
in classAbstractProtobufLogWriter
- Throws:
IOException
-
writeWALTrailerAndMagic
protected long writeWALTrailerAndMagic(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALTrailer trailer, byte[] magic) throws IOException - Specified by:
writeWALTrailerAndMagic
in classAbstractProtobufLogWriter
- Throws:
IOException
-
getOutputStreamForCellEncoder
- Specified by:
getOutputStreamForCellEncoder
in classAbstractProtobufLogWriter
-
getSyncedLength
Description copied from interface:WALProvider.WriterBase
NOTE: We add this method forWALFileLengthProvider
used for replication, considering the case if we useAsyncFSWAL
,we write to 3 DNs concurrently, according to the visibility guarantee of HDFS, the data will be available immediately when arriving at DN since all the DNs will be considered as the last one in pipeline. This means replication may read uncommitted data and replicate it to the remote cluster and cause data inconsistency. The methodWALProvider.WriterBase.getLength()
may return length which just in hdfs client buffer and not successfully synced to HDFS, so we use this method to return the length successfully synced to HDFS and replication thread could only read writing WAL file limited by this length. see also HBASE-14004 and this document for more details: https://docs.google.com/document/d/11AyWtGhItQs6vsLRIx32PwTxmBY3libXwGXI25obVEY/edit#- Specified by:
getSyncedLength
in interfaceWALProvider.WriterBase
- Returns:
- byteSize successfully synced to underlying filesystem.
-