Class FSHLog
java.lang.Object
org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL<WALProvider.Writer>
org.apache.hadoop.hbase.regionserver.wal.FSHLog
- All Implemented Interfaces:
Closeable
,AutoCloseable
,WALFileLengthProvider
,WAL
The original implementation of FSWAL.
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
private class
Thread to runs the hdfs sync call. -
Field Summary
Modifier and TypeFieldDescriptionprivate final AtomicInteger
private static final int
private static final int
private static final int
private static final int
static final long
private static final String
private org.apache.hadoop.fs.FSDataOutputStream
FSDataOutputStream associated with the current SequenceFile.writerprivate static final org.slf4j.Logger
private static final String
private boolean
private final int
private static final String
private final int
private final int
private static final String
private final int
private int
Which syncrunner to use next.private FSHLog.SyncRunner[]
private static final String
private static final IOException
private static final IOException
private static final IOException
Fields inherited from class org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL
abortable, blocksize, closed, closeExecutor, conf, consumeExecutor, consumer, coprocessorHost, DEFAULT_ROLL_ON_SYNC_TIME_MS, DEFAULT_SLOW_SYNC_ROLL_INTERVAL_MS, DEFAULT_SLOW_SYNC_ROLL_THRESHOLD, DEFAULT_SLOW_SYNC_TIME_MS, DEFAULT_WAL_BATCH_SIZE, DEFAULT_WAL_SHUTDOWN_WAIT_TIMEOUT_MS, DEFAULT_WAL_SYNC_TIMEOUT_MS, filenum, fs, hasConsumerTask, highestProcessedAppendTxid, highestSyncedTxid, highestUnsyncedTxid, implClassName, inflightWALClosures, listeners, LOG_NAME_COMPARATOR, logrollsize, MAX_LOGS, maxLogs, numEntries, ourFiles, prefixPathStr, RING_BUFFER_SLOT_COUNT, ROLL_ON_SYNC_TIME_MS, rollOnSyncNs, rollRequested, rollWriterLock, sequenceIdAccounting, shouldShutDownConsumeExecutorWhenClose, shutdown, SLOW_SYNC_ROLL_INTERVAL_MS, SLOW_SYNC_ROLL_THRESHOLD, SLOW_SYNC_TIME_MS, slowSyncCheckInterval, slowSyncCount, slowSyncNs, slowSyncRollThreshold, syncFutureCache, syncFutures, totalLogSize, toWriteAppends, unackedAppends, useHsync, WAL_AVOID_LOCAL_WRITES_DEFAULT, WAL_AVOID_LOCAL_WRITES_KEY, WAL_BATCH_SIZE, WAL_ROLL_MULTIPLIER, WAL_SHUTDOWN_WAIT_TIMEOUT_MS, WAL_SYNC_TIMEOUT_MS, walArchiveDir, walDir, walFile2Props, walFilePrefix, walFileSuffix, walShutdownTimeout, writer
-
Constructor Summary
ConstructorDescriptionFSHLog
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, String logDir, String archiveDir, org.apache.hadoop.conf.Configuration conf, List<WALActionsListener> listeners, boolean failIfWALExists, String prefix, String suffix) FSHLog
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path root, String logDir, org.apache.hadoop.conf.Configuration conf) Constructor.FSHLog
(org.apache.hadoop.fs.FileSystem fs, Abortable abortable, org.apache.hadoop.fs.Path rootDir, String logDir, String archiveDir, org.apache.hadoop.conf.Configuration conf, List<WALActionsListener> listeners, boolean failIfWALExists, String prefix, String suffix, org.apache.hadoop.fs.FileSystem remoteFs, org.apache.hadoop.fs.Path remoteWALDir) Create an edit log at the givendir
location.FSHLog
(org.apache.hadoop.fs.FileSystem fs, Abortable abortable, org.apache.hadoop.fs.Path root, String logDir, org.apache.hadoop.conf.Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected WALProvider.Writer
createCombinedWriter
(WALProvider.Writer localWriter, WALProvider.Writer remoteWriter) private void
protected WALProvider.Writer
createWriterInstance
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) This method allows subclasses to inject different writers without having to extend other methods like rollWriter().protected void
doAppend
(WALProvider.Writer writer, FSWALEntry entry) protected boolean
Returns true if number of replicas for the WAL is lower than thresholdprotected void
protected CompletableFuture<Long>
doWriterSync
(WALProvider.Writer writer, boolean shouldUseHSync, long txidWhenSync) (package private) int
This method gets the datanode replication count for the current WAL.(package private) OutputStream
Currently, we need to expose the writer's OutputStream to tests so that they can manipulate the default behavior (such as setting the maxRecoveryErrorCount value).(package private) org.apache.hadoop.hdfs.protocol.DatanodeInfo[]
This method gets the pipeline for the current WAL.void
init()
Used to initialize the WAL.(package private) boolean
private void
offerSyncRequest
(FSHLog.SyncRequest syncRequest) protected void
onWriterReplaced
(WALProvider.Writer nextWriter) private void
preemptiveSync
(ProtobufLogWriter nextWriter) Run a sync after opening to set up the pipeline.private void
Methods inherited from class org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL
abortCacheFlush, append, appendData, appendEntry, appendMarker, archive, archiveLogFile, atHeadOfRingBufferEventHandlerAppend, blockOnSync, checkLogLowReplication, close, closeWriter, completeCacheFlush, computeFilename, createSingleThreadPoolConsumeExecutor, doCheckSlowSync, doReplaceWriter, doShutdown, doSync, doSync, findRegionsToForceFlush, getCoprocessorHost, getCurrentFileName, getEarliestMemStoreSeqNum, getFilenum, getFileNumFromFileName, getFiles, getInflightWALCloseCount, getLogFileSize, getLogFileSizeIfBeingWritten, getNumLogFiles, getNumRolledLogFiles, getOldPath, getPreallocatedEventCount, getSequenceIdAccounting, getSyncedTxid, getSyncFuture, getUnflushedEntriesCount, getWALArchivePath, getWriter, isLogRollRequested, isUnflushedEntries, isWriterBroken, logRollAndSetupWalProps, main, markFutureDoneAndOffer, postSync, registerWALActionsListener, replaceWriter, requestLogRoll, requestLogRoll, rollWriter, rollWriter, setWaitOnShutdownInSeconds, shutdown, skipRemoteWAL, stampSequenceIdAndPublishToRingBuffer, startCacheFlush, startCacheFlush, sync, sync, sync, sync, toString, unregisterWALActionsListener, updateStore, waitForSafePoint
-
Field Details
-
LOG
-
TOLERABLE_LOW_REPLICATION
- See Also:
-
LOW_REPLICATION_ROLL_LIMIT
- See Also:
-
DEFAULT_LOW_REPLICATION_ROLL_LIMIT
- See Also:
-
SYNCER_COUNT
- See Also:
-
DEFAULT_SYNCER_COUNT
- See Also:
-
MAX_BATCH_COUNT
- See Also:
-
DEFAULT_MAX_BATCH_COUNT
- See Also:
-
FSHLOG_WAIT_ON_SHUTDOWN_IN_SECONDS
- See Also:
-
DEFAULT_FSHLOG_WAIT_ON_SHUTDOWN_IN_SECONDS
- See Also:
-
WITER_REPLACED_EXCEPTION
-
WITER_BROKEN_EXCEPTION
-
WAL_CLOSE_EXCEPTION
-
hdfs_out
FSDataOutputStream associated with the current SequenceFile.writer -
minTolerableReplication
-
consecutiveLogRolls
-
lowReplicationRollLimit
-
lowReplicationRollEnabled
-
syncerCount
-
maxSyncRequestCount
-
syncRunnerIndex
Which syncrunner to use next. -
syncRunners
-
FIXED_OVERHEAD
-
-
Constructor Details
-
FSHLog
public FSHLog(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path root, String logDir, org.apache.hadoop.conf.Configuration conf) throws IOException Constructor.- Parameters:
fs
- filesystem handleroot
- path for stored and archived walslogDir
- dir where wals are storedconf
- configuration to use- Throws:
IOException
-
FSHLog
public FSHLog(org.apache.hadoop.fs.FileSystem fs, Abortable abortable, org.apache.hadoop.fs.Path root, String logDir, org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
FSHLog
public FSHLog(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootDir, String logDir, String archiveDir, org.apache.hadoop.conf.Configuration conf, List<WALActionsListener> listeners, boolean failIfWALExists, String prefix, String suffix) throws IOException - Throws:
IOException
-
FSHLog
public FSHLog(org.apache.hadoop.fs.FileSystem fs, Abortable abortable, org.apache.hadoop.fs.Path rootDir, String logDir, String archiveDir, org.apache.hadoop.conf.Configuration conf, List<WALActionsListener> listeners, boolean failIfWALExists, String prefix, String suffix, org.apache.hadoop.fs.FileSystem remoteFs, org.apache.hadoop.fs.Path remoteWALDir) throws IOException Create an edit log at the givendir
location. You should never have to load an existing log. If there is a log at startup, it should have already been processed and deleted by the time the WAL object is started up.- Parameters:
fs
- filesystem handleabortable
- Abortable - the server hererootDir
- path to where logs and oldlogslogDir
- dir where wals are storedarchiveDir
- dir where wals are archivedconf
- configuration to uselisteners
- Listeners on WAL events. Listeners passed here will be registered before we do anything else; e.g. the ConstructorAbstractFSWAL.rollWriter()
.failIfWALExists
- If true IOException will be thrown if files related to this wal already exist.prefix
- should always be hostname and port in distributed env and it will be URL encoded before being used. If prefix is null, "wal" will be usedsuffix
- will be url encoded. null is treated as empty. non-empty must start withAbstractFSWALProvider.WAL_FILE_NAME_DELIMITER
- Throws:
IOException
-
-
Method Details
-
init
Description copied from class:AbstractFSWAL
Used to initialize the WAL. Usually just call rollWriter to create the first log writer.- Specified by:
init
in interfaceWAL
- Overrides:
init
in classAbstractFSWAL<WALProvider.Writer>
- Throws:
IOException
-
createSyncRunnersAndStart
-
getOutputStream
Currently, we need to expose the writer's OutputStream to tests so that they can manipulate the default behavior (such as setting the maxRecoveryErrorCount value). This is done using reflection on the underlying HDFS OutputStream. NOTE: This could be removed once Hadoop1 support is removed.- Returns:
- null if underlying stream is not ready.
-
preemptiveSync
Run a sync after opening to set up the pipeline. -
createWriterInstance
protected WALProvider.Writer createWriterInstance(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException This method allows subclasses to inject different writers without having to extend other methods like rollWriter().- Specified by:
createWriterInstance
in classAbstractFSWAL<WALProvider.Writer>
- Returns:
- Writer instance
- Throws:
IOException
-
doAppend
- Specified by:
doAppend
in classAbstractFSWAL<WALProvider.Writer>
- Throws:
IOException
-
onWriterReplaced
- Specified by:
onWriterReplaced
in classAbstractFSWAL<WALProvider.Writer>
-
doCleanUpResources
- Overrides:
doCleanUpResources
in classAbstractFSWAL<WALProvider.Writer>
-
shutDownSyncRunners
-
doWriterSync
protected CompletableFuture<Long> doWriterSync(WALProvider.Writer writer, boolean shouldUseHSync, long txidWhenSync) - Specified by:
doWriterSync
in classAbstractFSWAL<WALProvider.Writer>
-
offerSyncRequest
-
checkSlowSyncCount
- Overrides:
checkSlowSyncCount
in classAbstractFSWAL<WALProvider.Writer>
-
doCheckLogLowReplication
Returns true if number of replicas for the WAL is lower than threshold- Specified by:
doCheckLogLowReplication
in classAbstractFSWAL<WALProvider.Writer>
-
getLogReplication
int getLogReplication()This method gets the datanode replication count for the current WAL.If the pipeline isn't started yet or is empty, you will get the default replication factor. Therefore, if this function returns 0, it means you are not properly running with the HDFS-826 patch.
- Specified by:
getLogReplication
in classAbstractFSWAL<WALProvider.Writer>
-
isLowReplicationRollEnabled
boolean isLowReplicationRollEnabled() -
getPipeline
org.apache.hadoop.hdfs.protocol.DatanodeInfo[] getPipeline()This method gets the pipeline for the current WAL.- Specified by:
getPipeline
in classAbstractFSWAL<WALProvider.Writer>
-
createCombinedWriter
protected WALProvider.Writer createCombinedWriter(WALProvider.Writer localWriter, WALProvider.Writer remoteWriter) - Specified by:
createCombinedWriter
in classAbstractFSWAL<WALProvider.Writer>
-