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
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
protected org.apache.hadoop.fs.FSDataOutputStream
private final AtomicLong
Fields inherited from class org.apache.hadoop.hbase.regionserver.wal.AbstractProtobufLogWriter
cellEncoder, compressionContext, compressor, conf, encryptor, length, trailer, trailerWarnSize, trailerWritten
-
Constructor Summary
-
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
org.apache.hadoop.fs.FSDataOutputStream
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) void
sync
(boolean forceSync) protected long
writeMagicAndWALHeader
(byte[] magic, org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.WALHeader header) return the file length after written.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.FSHLogProvider.Writer
init
Methods 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:
append
in interfaceWALProvider.Writer
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
sync
- Specified by:
sync
in interfaceWALProvider.Writer
- Throws:
IOException
-
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.
-
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:
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
-
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
-
getOutputStreamForCellEncoder
- Specified by:
getOutputStreamForCellEncoder
in classAbstractProtobufLogWriter
-
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
-