Class WALProcedureStore
java.lang.Object
org.apache.hadoop.hbase.procedure2.store.ProcedureStoreBase
org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore
- All Implemented Interfaces:
ProcedureStore
Deprecated.
Since 2.3.0, will be removed in 4.0.0. Keep here only for rolling upgrading, now we
use the new region based procedure store.
WAL implementation of the ProcedureStore.
When starting, the upper layer will first call
start(int), then recoverLease(),
then load(ProcedureLoader).
In recoverLease(), we will get the lease by closing all the existing wal files(by
calling recoverFileLease), and creating a new wal writer. And we will also get the list of all
the old wal files.
FIXME: notice that the current recover lease implementation is problematic, it can not deal with
the races if there are two master both wants to acquire the lease...
In load(ProcedureLoader) method, we will load all the active procedures. See the
comments of this method for more details.
The actual logging way is a bit like our FileSystem based WAL implementation as RS side. There is
a slots, which is more like the ring buffer, and in the insert, update and delete
methods we will put thing into the slots and wait. And there is a background sync
thread(see the syncLoop() method) which get data from the slots and write them
to the FileSystem, and notify the caller that we have finished.
TODO: try using disruptor to increase performance and simplify the logic?
The storeTracker keeps track of the modified procedures in the newest wal file, which is
also the one being written currently. And the deleted bits in it are for all the procedures, not
only the ones in the newest wal file. And when rolling a log, we will first store it in the
trailer of the current wal file, and then reset its modified bits, so that it can start to track
the modified procedures for the new wal file.
The holdingCleanupTracker is used to test whether we are safe to delete the oldest wal
file. When there are log rolling and there are more than 1 wal files, we will make use of it. It
will first be initialized to the oldest file's tracker(which is stored in the trailer), using the
method ProcedureStoreTracker.resetTo(ProcedureStoreTracker, boolean), and then merge it
with the tracker of every newer wal files, using the
ProcedureStoreTracker.setDeletedIfModifiedInBoth(ProcedureStoreTracker). If we find out
that all the modified procedures for the oldest wal file are modified or deleted in newer wal
files, then we can delete it. This is because that, every time we call
ProcedureStore.insert(Procedure[]) or ProcedureStore.update(Procedure), we will
persist the full state of a Procedure, so the earlier wal records for this procedure can all be
deleted.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumDeprecated.static classDeprecated.Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.procedure2.store.ProcedureStore
ProcedureStore.ProcedureIterator, ProcedureStore.ProcedureLoader, ProcedureStore.ProcedureStoreListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.ConfigurationDeprecated.private Set<ProcedureWALFile>Deprecated.private static final booleanDeprecated.private static final intDeprecated.private static final intDeprecated.private static final intDeprecated.private static final intDeprecated.private static final longDeprecated.private static final intDeprecated.private static final intDeprecated.private static final booleanDeprecated.private static final intDeprecated.private static final intDeprecated.private final booleanDeprecated.static final StringDeprecated.private static final Comparator<org.apache.hadoop.fs.FileStatus>Deprecated.private longDeprecated.private final org.apache.hadoop.fs.FileSystemDeprecated.private final ProcedureStoreTrackerDeprecated.private final AtomicBooleanDeprecated.private final AtomicLongDeprecated.private final LeaseRecoveryDeprecated.private final AtomicBooleanDeprecated.private final ReentrantLockDeprecated.private static final org.slf4j.LoggerDeprecated.static final StringDeprecated.private final LinkedList<ProcedureWALFile>Deprecated.static final StringDeprecated.Used to construct the name of the log directory for master proceduresstatic final StringDeprecated.static final StringDeprecated.private intDeprecated.private intDeprecated.static final StringDeprecated.private intDeprecated.static final StringDeprecated.static final StringDeprecated.private intDeprecated.private longDeprecated.private intDeprecated.private final ConditionDeprecated.private intDeprecated.private ByteSlot[]Deprecated.private LinkedTransferQueue<ByteSlot>Deprecated.static final StringDeprecated.private final ProcedureStoreTrackerDeprecated.private org.apache.hadoop.fs.FSDataOutputStreamDeprecated.static final StringDeprecated.private final ConditionDeprecated.private final AtomicReference<Throwable>Deprecated.private final AtomicLongDeprecated.private intDeprecated.private org.apache.hbase.thirdparty.org.apache.commons.collections4.queue.CircularFifoQueue<WALProcedureStore.SyncMetrics>Deprecated.private ThreadDeprecated.private intDeprecated.private final AtomicLongDeprecated.static final StringDeprecated.private booleanDeprecated.static final StringDeprecated.private intDeprecated.private final ConditionDeprecated.static final StringDeprecated.private final org.apache.hadoop.fs.PathDeprecated.private intDeprecated.private final org.apache.hadoop.fs.PathDeprecated.private static final org.apache.hadoop.fs.PathFilterDeprecated. -
Constructor Summary
ConstructorsConstructorDescriptionWALProcedureStore(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path walDir, org.apache.hadoop.fs.Path walArchiveDir, LeaseRecovery leaseRecovery) Deprecated.WALProcedureStore(org.apache.hadoop.conf.Configuration conf, LeaseRecovery leaseRecovery) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprivate ByteSlotDeprecated.private voidDeprecated.private voidcloseCurrentLogStream(boolean abort) Deprecated.voiddelete(long procId) Deprecated.The specified procId was removed from the executor, due to completion, abort or failure.private voiddelete(long[] procIds) Deprecated.voiddelete(long[] procIds, int offset, int count) Deprecated.The specified procIds were removed from the executor, due to completion, abort or failure.voidDeprecated.The parent procedure completed.Deprecated.Deprecated.org.apache.hadoop.fs.FileSystemDeprecated.protected org.apache.hadoop.fs.PathgetLogFilePath(long logId) Deprecated.private org.apache.hadoop.fs.FileStatus[]Deprecated.private static longgetLogIdFromName(String name) Deprecated.private static longgetMaxLogId(org.apache.hadoop.fs.FileStatus[] logFiles) Deprecated.Make sure that the file set are gotten by callinggetLogFiles(), where we will sort the file set by log id.longDeprecated.longDeprecated.intDeprecated.Returns the number of threads/slots passed to start()Deprecated.Deprecated.(package private) org.apache.hadoop.fs.PathDeprecated.org.apache.hadoop.fs.PathDeprecated.private ProcedureWALFileinitOldLog(org.apache.hadoop.fs.FileStatus logFile, org.apache.hadoop.fs.Path walArchiveDir) Deprecated.Loads given log file and it's tracker.private longinitOldLogs(org.apache.hadoop.fs.FileStatus[] logFiles) Deprecated.Make sure that the file set are gotten by callinggetLogFiles(), where we will sort the file set by log id.private voidDeprecated.If last log's tracker is not null, use it asstoreTracker.voidDeprecated.Serialize a set of new procedures.voidDeprecated.When a procedure is submitted to the executor insert(proc, null) will be called.private booleanDeprecated.voidload(ProcedureStore.ProcedureLoader loader) Deprecated.Load the Procedures in the store.static voidDeprecated.Parses a directory of WALs building up ProcedureState.private voidDeprecated.(package private) voidDeprecated.private longpushData(WALProcedureStore.PushType type, ByteSlot slot, long procId, long[] subProcIds) Deprecated.voidDeprecated.Acquire the lease for the procedure store.private voidreleaseSlot(ByteSlot slot) Deprecated.private voidremoveAllLogs(long lastLogId, String why) Deprecated.Remove all logs with logId <=lastLogId.private voidDeprecated.(package private) voidDeprecated.private booleanremoveLogFile(ProcedureWALFile log, org.apache.hadoop.fs.Path walArchiveDir) Deprecated.private booleanDeprecated.(package private) booleanrollWriter(long logId) Deprecated.booleanDeprecated.private booleanDeprecated.private voidDeprecated.intsetRunningProcedureCount(int count) Deprecated.Set the number of procedure running.voidstart(int numSlots) Deprecated.Start/Open the procedure storevoidstop(boolean abort) Deprecated.Stop/Close the procedure storeprivate voidsyncLoop()Deprecated.private longDeprecated.protected longDeprecated.protected voidsyncStream(org.apache.hadoop.fs.FSDataOutputStream stream) Deprecated.private voidDeprecated.private booleanDeprecated.voidDeprecated.The specified procedure was executed, and the new state should be written to the store.private voidupdateStoreTracker(WALProcedureStore.PushType type, long procId, long[] subProcIds) Deprecated.Methods inherited from class org.apache.hadoop.hbase.procedure2.store.ProcedureStoreBase
isRunning, registerListener, sendAbortProcessSignal, sendForceUpdateSignal, sendPostSyncSignal, setRunning, unregisterListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.procedure2.store.ProcedureStore
cleanup
-
Field Details
-
LOG
Deprecated. -
LOG_PREFIX
Deprecated.- See Also:
-
MASTER_PROCEDURE_LOGDIR
Deprecated.Used to construct the name of the log directory for master procedures- See Also:
-
WAL_COUNT_WARN_THRESHOLD_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_WAL_COUNT_WARN_THRESHOLD
Deprecated.- See Also:
-
EXEC_WAL_CLEANUP_ON_LOAD_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_EXEC_WAL_CLEANUP_ON_LOAD_CONF_KEY
Deprecated.- See Also:
-
MAX_RETRIES_BEFORE_ROLL_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_MAX_RETRIES_BEFORE_ROLL
Deprecated.- See Also:
-
WAIT_BEFORE_ROLL_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_WAIT_BEFORE_ROLL
Deprecated.- See Also:
-
ROLL_RETRIES_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_ROLL_RETRIES
Deprecated.- See Also:
-
MAX_SYNC_FAILURE_ROLL_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_MAX_SYNC_FAILURE_ROLL
Deprecated.- See Also:
-
PERIODIC_ROLL_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_PERIODIC_ROLL
Deprecated.- See Also:
-
SYNC_WAIT_MSEC_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_SYNC_WAIT_MSEC
Deprecated.- See Also:
-
USE_HSYNC_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_USE_HSYNC
Deprecated.- See Also:
-
ROLL_THRESHOLD_CONF_KEY
Deprecated.- See Also:
-
DEFAULT_ROLL_THRESHOLD
Deprecated.- See Also:
-
STORE_WAL_SYNC_STATS_COUNT
Deprecated.- See Also:
-
DEFAULT_SYNC_STATS_COUNT
Deprecated.- See Also:
-
logs
Deprecated. -
holdingCleanupTracker
Deprecated. -
storeTracker
Deprecated. -
lock
Deprecated. -
waitCond
Deprecated. -
slotCond
Deprecated. -
syncCond
Deprecated. -
leaseRecovery
Deprecated. -
conf
Deprecated. -
fs
Deprecated. -
walDir
Deprecated. -
walArchiveDir
Deprecated. -
enforceStreamCapability
Deprecated. -
syncException
Deprecated. -
loading
Deprecated. -
inSync
Deprecated. -
totalSynced
Deprecated. -
lastRollTs
Deprecated. -
syncId
Deprecated. -
slotsCache
Deprecated. -
corruptedLogs
Deprecated. -
stream
Deprecated. -
runningProcCount
Deprecated. -
flushLogId
Deprecated. -
syncMaxSlot
Deprecated. -
slotIndex
Deprecated. -
syncThread
Deprecated. -
slots
Deprecated. -
walCountWarnThreshold
Deprecated. -
maxRetriesBeforeRoll
Deprecated. -
maxSyncFailureRoll
Deprecated. -
waitBeforeRoll
Deprecated. -
rollRetries
Deprecated. -
periodicRollMsec
Deprecated. -
rollThreshold
Deprecated. -
useHsync
Deprecated. -
syncWaitMsec
Deprecated. -
syncMetricsQueue
private org.apache.hbase.thirdparty.org.apache.commons.collections4.queue.CircularFifoQueue<WALProcedureStore.SyncMetrics> syncMetricsQueueDeprecated. -
WALS_PATH_FILTER
Deprecated. -
FILE_STATUS_ID_COMPARATOR
Deprecated.
-
-
Constructor Details
-
WALProcedureStore
public WALProcedureStore(org.apache.hadoop.conf.Configuration conf, LeaseRecovery leaseRecovery) throws IOException Deprecated.- Throws:
IOException
-
WALProcedureStore
public WALProcedureStore(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path walDir, org.apache.hadoop.fs.Path walArchiveDir, LeaseRecovery leaseRecovery) throws IOException Deprecated.- Throws:
IOException
-
-
Method Details
-
start
Deprecated.Description copied from interface:ProcedureStoreStart/Open the procedure store- Parameters:
numSlots- number of threads to be used by the procedure store- Throws:
IOException
-
stop
Deprecated.Description copied from interface:ProcedureStoreStop/Close the procedure store- Parameters:
abort- true if the stop is an abort
-
sendStopSignal
Deprecated. -
getNumThreads
Deprecated.Description copied from interface:ProcedureStoreReturns the number of threads/slots passed to start() -
setRunningProcedureCount
Deprecated.Description copied from interface:ProcedureStoreSet the number of procedure running. This can be used, for example, by the store to know how long to wait before a sync.- Returns:
- how many procedures are running (may not be same as
count).
-
getStoreTracker
Deprecated. -
getActiveLogs
Deprecated. -
getCorruptedLogs
Deprecated. -
recoverLease
Deprecated.Description copied from interface:ProcedureStoreAcquire the lease for the procedure store.- Throws:
IOException
-
load
Deprecated.Description copied from interface:ProcedureStoreLoad the Procedures in the store.- Parameters:
loader- the ProcedureLoader that will handle the store-load events- Throws:
IOException
-
tryCleanupLogsOnLoad
Deprecated. -
insert
Deprecated.Description copied from interface:ProcedureStoreWhen a procedure is submitted to the executor insert(proc, null) will be called. 'proc' has a 'RUNNABLE' state and the initial information required to start up. When a procedure is executed and it returns children insert(proc, subprocs) will be called. 'proc' has a 'WAITING' state and an update state. 'subprocs' are the children in 'RUNNABLE' state with the initial information.- Parameters:
proc- the procedure to serialize and write to the store.subprocs- the newly created child of the proc.
-
insert
Deprecated.Description copied from interface:ProcedureStoreSerialize a set of new procedures. These procedures are freshly submitted to the executor and each procedure has a 'RUNNABLE' state and the initial information required to start up.- Parameters:
procs- the procedures to serialize and write to the store.
-
update
Deprecated.Description copied from interface:ProcedureStoreThe specified procedure was executed, and the new state should be written to the store.- Parameters:
proc- the procedure to serialize and write to the store.
-
delete
Deprecated.Description copied from interface:ProcedureStoreThe specified procId was removed from the executor, due to completion, abort or failure. The store implementor should remove all the information about the specified procId.- Parameters:
procId- the ID of the procedure to remove.
-
delete
Deprecated.Description copied from interface:ProcedureStoreThe parent procedure completed. Update the state and mark all the child deleted.- Parameters:
proc- the parent procedure to serialize and write to the store.subProcIds- the IDs of the sub-procedure to remove.
-
delete
Deprecated.Description copied from interface:ProcedureStoreThe specified procIds were removed from the executor, due to completion, abort or failure. The store implementor should remove all the information about the specified procIds.- Parameters:
procIds- the IDs of the procedures to remove.offset- the array offset from where to start to deletecount- the number of IDs to delete
-
delete
Deprecated. -
acquireSlot
Deprecated. -
releaseSlot
Deprecated. -
pushData
private long pushData(WALProcedureStore.PushType type, ByteSlot slot, long procId, long[] subProcIds) Deprecated. -
updateStoreTracker
Deprecated. -
isSyncAborted
Deprecated. -
syncLoop
Deprecated.- Throws:
Throwable
-
getSyncMetrics
Deprecated. -
syncSlots
Deprecated.- Throws:
Throwable
-
syncSlots
protected long syncSlots(org.apache.hadoop.fs.FSDataOutputStream stream, ByteSlot[] slots, int offset, int count) throws IOException Deprecated.- Throws:
IOException
-
syncStream
Deprecated.- Throws:
IOException
-
rollWriterWithRetries
Deprecated. -
tryRollWriter
Deprecated. -
getMillisToNextPeriodicRoll
Deprecated. -
getMillisFromLastRoll
Deprecated. -
periodicRollForTesting
Deprecated.- Throws:
IOException
-
rollWriterForTesting
Deprecated.- Throws:
IOException
-
removeInactiveLogsForTesting
Deprecated.- Throws:
Exception
-
periodicRoll
Deprecated.- Throws:
IOException
-
rollWriter
Deprecated.- Throws:
IOException
-
rollWriter
Deprecated.- Throws:
IOException
-
closeCurrentLogStream
Deprecated. -
removeInactiveLogs
Deprecated.- Throws:
IOException
-
buildHoldingCleanupTracker
Deprecated. -
removeAllLogs
Deprecated.Remove all logs with logId <=lastLogId. -
removeLogFile
Deprecated. -
getWALDir
Deprecated. -
getWalArchiveDir
org.apache.hadoop.fs.Path getWalArchiveDir()Deprecated. -
getFileSystem
Deprecated. -
getLogFilePath
Deprecated.- Throws:
IOException
-
getLogIdFromName
Deprecated. -
getLogFiles
Deprecated.- Throws:
IOException
-
getMaxLogId
Deprecated.Make sure that the file set are gotten by callinggetLogFiles(), where we will sort the file set by log id.- Returns:
- Max-LogID of the specified log file set
-
initOldLogs
Deprecated.Make sure that the file set are gotten by callinggetLogFiles(), where we will sort the file set by log id.- Returns:
- Max-LogID of the specified log file set
- Throws:
IOException
-
initTrackerFromOldLogs
Deprecated.If last log's tracker is not null, use it asstoreTracker. Otherwise, set storeTracker as partial, and letProcedureWALFormatReaderrebuild it using entries in the log. -
initOldLog
private ProcedureWALFile initOldLog(org.apache.hadoop.fs.FileStatus logFile, org.apache.hadoop.fs.Path walArchiveDir) throws IOException Deprecated.Loads given log file and it's tracker.- Throws:
IOException
-
main
Deprecated.Parses a directory of WALs building up ProcedureState. For testing parse and profiling.- Parameters:
args- Include pointer to directory of WAL files for a store instance to parse & load.- Throws:
IOException
-