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
Nested ClassesModifier and TypeClassDescription(package private) static classprivate classThread to runs the hdfs sync call. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicIntegerprivate static final intprivate static final intprivate static final intprivate static final intstatic final longprivate static final Stringprivate org.apache.hadoop.fs.FSDataOutputStreamFSDataOutputStream associated with the current SequenceFile.writerprivate static final org.slf4j.Loggerprivate static final Stringprivate booleanprivate final intprivate static final Stringprivate final intprivate final intprivate static final Stringprivate final intprivate intWhich syncrunner to use next.private FSHLog.SyncRunner[]private static final Stringprivate static final IOExceptionprivate static final IOExceptionprivate static final IOExceptionFields 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
ConstructorsConstructorDescriptionFSHLog(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 givendirlocation.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 voidprotected WALProvider.WritercreateCombinedWriter(WALProvider.Writer localWriter, WALProvider.Writer remoteWriter) private voidprotected WALProvider.WritercreateWriterInstance(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 voiddoAppend(WALProvider.Writer writer, FSWALEntry entry) protected booleanReturns true if number of replicas for the WAL is lower than thresholdprotected voidprotected CompletableFuture<Long>doWriterSync(WALProvider.Writer writer, boolean shouldUseHSync, long txidWhenSync) (package private) intThis method gets the datanode replication count for the current WAL.(package private) OutputStreamCurrently, 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.voidinit()Used to initialize the WAL.(package private) booleanprivate voidofferSyncRequest(FSHLog.SyncRequest syncRequest) protected voidonWriterReplaced(WALProvider.Writer nextWriter) private voidpreemptiveSync(ProtobufLogWriter nextWriter) Run a sync after opening to set up the pipeline.private voidMethods 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 givendirlocation. 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:AbstractFSWALUsed to initialize the WAL. Usually just call rollWriter to create the first log writer.- Specified by:
initin interfaceWAL- Overrides:
initin 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:
createWriterInstancein classAbstractFSWAL<WALProvider.Writer>- Returns:
- Writer instance
- Throws:
IOException
-
doAppend
- Specified by:
doAppendin classAbstractFSWAL<WALProvider.Writer>- Throws:
IOException
-
onWriterReplaced
- Specified by:
onWriterReplacedin classAbstractFSWAL<WALProvider.Writer>
-
doCleanUpResources
- Overrides:
doCleanUpResourcesin classAbstractFSWAL<WALProvider.Writer>
-
shutDownSyncRunners
-
doWriterSync
protected CompletableFuture<Long> doWriterSync(WALProvider.Writer writer, boolean shouldUseHSync, long txidWhenSync) - Specified by:
doWriterSyncin classAbstractFSWAL<WALProvider.Writer>
-
offerSyncRequest
-
checkSlowSyncCount
- Overrides:
checkSlowSyncCountin classAbstractFSWAL<WALProvider.Writer>
-
doCheckLogLowReplication
Returns true if number of replicas for the WAL is lower than threshold- Specified by:
doCheckLogLowReplicationin 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:
getLogReplicationin 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:
getPipelinein classAbstractFSWAL<WALProvider.Writer>
-
createCombinedWriter
protected WALProvider.Writer createCombinedWriter(WALProvider.Writer localWriter, WALProvider.Writer remoteWriter) - Specified by:
createCombinedWriterin classAbstractFSWAL<WALProvider.Writer>
-