Class ProtobufLogWriter
java.lang.Object
org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufLogWriter
org.apache.hadoop.hbase.regionserver.wal.ProtobufLogWriter
- All Implemented Interfaces:
Closeable,AutoCloseable,FSHLogProvider.Writer,WALProvider.Writer,WALProvider.WriterBase
@Private
public class ProtobufLogWriter
extends AbstractProtobufLogWriter
implements FSHLogProvider.Writer
Writer for protobuf-based WAL.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprotected org.apache.hadoop.fs.FSDataOutputStreamprivate final AtomicLongFields inherited from class org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufLogWriter
cellEncoder, compressionContext, compressor, conf, encryptor, length, trailer, trailerWarnSize, trailerWritten -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()protected voidIt is straight forward to close the output, do not need to write trailer like the Writer.closeprotected OutputStreamorg.apache.hadoop.fs.FSDataOutputStreamlongNOTE: We add this method forWALFileLengthProviderused 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 voidinitOutput(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, boolean overwritable, int bufferSize, short replication, long blockSize, StreamSlowMonitor monitor, boolean noLocalWrite) voidsync(boolean forceSync) protected longwriteMagicAndWALHeader(byte[] magic, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALHeader header) return the file length after written.protected longwriteWALTrailerAndMagic(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, writeWALTrailerMethods 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.FSHLogProvider.Writer
initMethods inherited from interface org.apache.hadoop.hbase.wal.WALProvider.WriterBase
getLength
-
Field Details
-
LOG
-
output
-
syncedLength
-
-
Constructor Details
-
ProtobufLogWriter
public ProtobufLogWriter()
-
-
Method Details
-
append
- Specified by:
appendin interfaceWALProvider.Writer- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
sync
- Specified by:
syncin interfaceWALProvider.Writer- Throws:
IOException
-
getSyncedLength
Description copied from interface:WALProvider.WriterBaseNOTE: We add this method forWALFileLengthProviderused 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:
getSyncedLengthin interfaceWALProvider.WriterBase- Returns:
- byteSize successfully synced to underlying filesystem.
-
getStream
-
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:
initOutputin classAbstractProtobufLogWriter- Throws:
IOExceptionCommonFSUtils.StreamLacksCapabilityException
-
closeOutputIfNecessary
Description copied from class:AbstractProtobufLogWriterIt is straight forward to close the output, do not need to write trailer like the Writer.close- Overrides:
closeOutputIfNecessaryin classAbstractProtobufLogWriter
-
writeMagicAndWALHeader
protected long writeMagicAndWALHeader(byte[] magic, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALHeader header) throws IOException Description copied from class:AbstractProtobufLogWriterreturn the file length after written.- Specified by:
writeMagicAndWALHeaderin classAbstractProtobufLogWriter- Throws:
IOException
-
getOutputStreamForCellEncoder
- Specified by:
getOutputStreamForCellEncoderin classAbstractProtobufLogWriter
-
writeWALTrailerAndMagic
protected long writeWALTrailerAndMagic(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALTrailer trailer, byte[] magic) throws IOException - Specified by:
writeWALTrailerAndMagicin classAbstractProtobufLogWriter- Throws:
IOException
-