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
Modifier and TypeClassDescriptionprivate static enum
Deprecated.static class
Deprecated.Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.procedure2.store.ProcedureStore
ProcedureStore.ProcedureIterator, ProcedureStore.ProcedureLoader, ProcedureStore.ProcedureStoreListener
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configuration
Deprecated.private Set<ProcedureWALFile>
Deprecated.private static final boolean
Deprecated.private static final int
Deprecated.private static final int
Deprecated.private static final int
Deprecated.private static final int
Deprecated.private static final long
Deprecated.private static final int
Deprecated.private static final int
Deprecated.private static final boolean
Deprecated.private static final int
Deprecated.private static final int
Deprecated.private final boolean
Deprecated.static final String
Deprecated.private static final Comparator<org.apache.hadoop.fs.FileStatus>
Deprecated.private long
Deprecated.private final org.apache.hadoop.fs.FileSystem
Deprecated.private final ProcedureStoreTracker
Deprecated.private final AtomicBoolean
Deprecated.private final AtomicLong
Deprecated.private final LeaseRecovery
Deprecated.private final AtomicBoolean
Deprecated.private final ReentrantLock
Deprecated.private static final org.slf4j.Logger
Deprecated.static final String
Deprecated.private final LinkedList<ProcedureWALFile>
Deprecated.static final String
Deprecated.Used to construct the name of the log directory for master proceduresstatic final String
Deprecated.static final String
Deprecated.private int
Deprecated.private int
Deprecated.static final String
Deprecated.private int
Deprecated.static final String
Deprecated.static final String
Deprecated.private int
Deprecated.private long
Deprecated.private int
Deprecated.private final Condition
Deprecated.private int
Deprecated.private ByteSlot[]
Deprecated.private LinkedTransferQueue<ByteSlot>
Deprecated.static final String
Deprecated.private final ProcedureStoreTracker
Deprecated.private org.apache.hadoop.fs.FSDataOutputStream
Deprecated.static final String
Deprecated.private final Condition
Deprecated.private final AtomicReference<Throwable>
Deprecated.private final AtomicLong
Deprecated.private int
Deprecated.private org.apache.hbase.thirdparty.org.apache.commons.collections4.queue.CircularFifoQueue<WALProcedureStore.SyncMetrics>
Deprecated.private Thread
Deprecated.private int
Deprecated.private final AtomicLong
Deprecated.static final String
Deprecated.private boolean
Deprecated.static final String
Deprecated.private int
Deprecated.private final Condition
Deprecated.static final String
Deprecated.private final org.apache.hadoop.fs.Path
Deprecated.private int
Deprecated.private final org.apache.hadoop.fs.Path
Deprecated.private static final org.apache.hadoop.fs.PathFilter
Deprecated. -
Constructor Summary
ConstructorDescriptionWALProcedureStore
(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 ByteSlot
Deprecated.private void
Deprecated.private void
closeCurrentLogStream
(boolean abort) Deprecated.void
delete
(long procId) Deprecated.The specified procId was removed from the executor, due to completion, abort or failure.private void
delete
(long[] procIds) Deprecated.void
delete
(long[] procIds, int offset, int count) Deprecated.The specified procIds were removed from the executor, due to completion, abort or failure.void
Deprecated.The parent procedure completed.Deprecated.Deprecated.org.apache.hadoop.fs.FileSystem
Deprecated.protected org.apache.hadoop.fs.Path
getLogFilePath
(long logId) Deprecated.private org.apache.hadoop.fs.FileStatus[]
Deprecated.private static long
getLogIdFromName
(String name) Deprecated.private static long
getMaxLogId
(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.long
Deprecated.long
Deprecated.int
Deprecated.Returns the number of threads/slots passed to start()Deprecated.Deprecated.(package private) org.apache.hadoop.fs.Path
Deprecated.org.apache.hadoop.fs.Path
Deprecated.private ProcedureWALFile
initOldLog
(org.apache.hadoop.fs.FileStatus logFile, org.apache.hadoop.fs.Path walArchiveDir) Deprecated.Loads given log file and it's tracker.private long
initOldLogs
(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 void
Deprecated.If last log's tracker is not null, use it asstoreTracker
.void
Deprecated.Serialize a set of new procedures.void
Deprecated.When a procedure is submitted to the executor insert(proc, null) will be called.private boolean
Deprecated.void
load
(ProcedureStore.ProcedureLoader loader) Deprecated.Load the Procedures in the store.static void
Deprecated.Parses a directory of WALs building up ProcedureState.private void
Deprecated.(package private) void
Deprecated.private long
pushData
(WALProcedureStore.PushType type, ByteSlot slot, long procId, long[] subProcIds) Deprecated.void
Deprecated.Acquire the lease for the procedure store.private void
releaseSlot
(ByteSlot slot) Deprecated.private void
removeAllLogs
(long lastLogId, String why) Deprecated.Remove all logs with logId <=lastLogId
.private void
Deprecated.(package private) void
Deprecated.private boolean
removeLogFile
(ProcedureWALFile log, org.apache.hadoop.fs.Path walArchiveDir) Deprecated.private boolean
Deprecated.(package private) boolean
rollWriter
(long logId) Deprecated.boolean
Deprecated.private boolean
Deprecated.private void
Deprecated.int
setRunningProcedureCount
(int count) Deprecated.Set the number of procedure running.void
start
(int numSlots) Deprecated.Start/Open the procedure storevoid
stop
(boolean abort) Deprecated.Stop/Close the procedure storeprivate void
syncLoop()
Deprecated.private long
Deprecated.protected long
Deprecated.protected void
syncStream
(org.apache.hadoop.fs.FSDataOutputStream stream) Deprecated.private void
Deprecated.private boolean
Deprecated.void
Deprecated.The specified procedure was executed, and the new state should be written to the store.private void
updateStoreTracker
(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, unregisterListener
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.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:ProcedureStore
Start/Open the procedure store- Parameters:
numSlots
- number of threads to be used by the procedure store- Throws:
IOException
-
stop
Deprecated.Description copied from interface:ProcedureStore
Stop/Close the procedure store- Parameters:
abort
- true if the stop is an abort
-
sendStopSignal
Deprecated. -
getNumThreads
Deprecated.Description copied from interface:ProcedureStore
Returns the number of threads/slots passed to start() -
setRunningProcedureCount
Deprecated.Description copied from interface:ProcedureStore
Set 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:ProcedureStore
Acquire the lease for the procedure store.- Throws:
IOException
-
load
Deprecated.Description copied from interface:ProcedureStore
Load 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:ProcedureStore
When 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:ProcedureStore
Serialize 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:ProcedureStore
The 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:ProcedureStore
The 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:ProcedureStore
The 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:ProcedureStore
The 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 letProcedureWALFormatReader
rebuild 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
-