Class TakeSnapshotHandler
java.lang.Object
org.apache.hadoop.hbase.executor.EventHandler
org.apache.hadoop.hbase.master.snapshot.TakeSnapshotHandler
- All Implemented Interfaces:
Comparable<EventHandler>
,Runnable
,ForeignExceptionSnare
,SnapshotSentinel
- Direct Known Subclasses:
DisabledTableSnapshotHandler
,EnabledTableSnapshotHandler
@Private
public abstract class TakeSnapshotHandler
extends EventHandler
implements SnapshotSentinel, ForeignExceptionSnare
A handler for taking snapshots from the master. This is not a subclass of TableEventHandler
because using that would incur an extra hbase:meta scan. The
snapshotRegions(List)
call
should get implemented for each snapshot flavor.-
Field Summary
Modifier and TypeFieldDescriptionprotected final org.apache.hadoop.conf.Configuration
private boolean
static final String
protected TableDescriptor
private final long
Snapshot creation requires table lock.private static final org.slf4j.Logger
protected final MasterServices
protected final MetricsSnapshot
protected final ForeignExceptionDispatcher
protected final org.apache.hadoop.fs.Path
protected final org.apache.hadoop.fs.FileSystem
protected final org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription
private final org.apache.hadoop.fs.Path
protected final SnapshotManager
protected final SnapshotManifest
protected final TableName
protected final MonitoredTask
private final LockManager.MasterLock
private final MasterSnapshotVerifier
protected final org.apache.hadoop.fs.Path
protected final org.apache.hadoop.fs.FileSystem
Fields inherited from class org.apache.hadoop.hbase.executor.EventHandler
eventType, seqids, server, waitingTimeForEvents
-
Constructor Summary
ConstructorDescriptionTakeSnapshotHandler
(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, MasterServices masterServices, SnapshotManager snapshotManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Actively cancel a running snapshot.protected abstract boolean
When taking snapshot, first we must acquire the exclusive table lock to confirm that there are no ongoing merge/split procedures.long
Returns -1 if the snapshot is in progress, otherwise the completion timestamp.Get the value of the captured exception.Get the exception that caused the snapshot to fail, if the snapshot has failed.org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription
Returns the description of the snapshot being runboolean
Non-exceptional form ofForeignExceptionSnare.rethrowException()
.boolean
Check to see if the snapshot is finished, where finished may be success or failure.private TableDescriptor
prepare()
Event handlers should do all the necessary checks in this method (rather than in the constructor, or in process()) so that the caller, which is mostly executed in the ipc context can fail fast.void
process()
Execute the core common portions of taking a snapshot.void
Rethrow an exception currently held by theForeignExceptionSnare
.void
Rethrow the exception returned bySnapshotSentinel.getExceptionIfFailed()
.protected void
snapshotDisabledRegion
(RegionInfo regionInfo) Take a snapshot of the specified disabled regionprotected abstract void
snapshotRegions
(List<Pair<RegionInfo, ServerName>> regions) Snapshot the specified regionsMethods inherited from class org.apache.hadoop.hbase.executor.EventHandler
compareTo, getEventType, getInformativeName, getPriority, getSeqid, handleException, run, toString
-
Field Details
-
LOG
-
HBASE_SNAPSHOT_MASTER_LOCK_ACQUIRE_TIMEOUT
- See Also:
-
finished
-
master
-
metricsSnapshot
-
snapshot
protected final org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot -
conf
-
rootFs
-
workingDirFs
-
rootDir
-
snapshotDir
-
workingDir
-
verifier
-
monitor
-
tableLock
-
status
-
snapshotTable
-
snapshotManifest
-
snapshotManager
-
lockAcquireTimeoutMs
Snapshot creation requires table lock. If any region of the table is in transition, table lock cannot be acquired by LockProcedure and hence snapshot creation could hang for potentially very long time. This timeout will ensure snapshot creation fails-fast by waiting for only given timeout. -
htd
-
-
Constructor Details
-
TakeSnapshotHandler
public TakeSnapshotHandler(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, MasterServices masterServices, SnapshotManager snapshotManager) throws IOException - Parameters:
snapshot
- descriptor of the snapshot to takemasterServices
- master services provider- Throws:
IllegalArgumentException
- if the working snapshot directory set from the configuration is the same as the completed snapshot directoryIOException
- if the file system of the working snapshot directory cannot be determined
-
-
Method Details
-
loadTableDescriptor
- Throws:
IOException
-
prepare
Description copied from class:EventHandler
Event handlers should do all the necessary checks in this method (rather than in the constructor, or in process()) so that the caller, which is mostly executed in the ipc context can fail fast. Process is executed async from the client ipc, so this method gives a quick chance to do some basic checks. Should be called after constructing the EventHandler, and before process().- Overrides:
prepare
in classEventHandler
- Returns:
- the instance of this class
- Throws:
Exception
- when something goes wrong
-
process
Execute the core common portions of taking a snapshot. ThesnapshotRegions(List)
call should get implemented for each snapshot flavor.- Specified by:
process
in classEventHandler
-
snapshotRegions
protected abstract void snapshotRegions(List<Pair<RegionInfo, ServerName>> regions) throws IOException, org.apache.zookeeper.KeeperExceptionSnapshot the specified regions- Throws:
IOException
org.apache.zookeeper.KeeperException
-
snapshotDisabledRegion
Take a snapshot of the specified disabled region- Throws:
IOException
-
cancel
Description copied from interface:SnapshotSentinel
Actively cancel a running snapshot.- Specified by:
cancel
in interfaceSnapshotSentinel
- Parameters:
why
- Reason for cancellation.
-
isFinished
Description copied from interface:SnapshotSentinel
Check to see if the snapshot is finished, where finished may be success or failure.- Specified by:
isFinished
in interfaceSnapshotSentinel
- Returns:
- false if the snapshot is still in progress, true if the snapshot has finished
-
getCompletionTimestamp
Description copied from interface:SnapshotSentinel
Returns -1 if the snapshot is in progress, otherwise the completion timestamp.- Specified by:
getCompletionTimestamp
in interfaceSnapshotSentinel
-
getSnapshot
public org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription getSnapshot()Description copied from interface:SnapshotSentinel
Returns the description of the snapshot being run- Specified by:
getSnapshot
in interfaceSnapshotSentinel
-
getExceptionIfFailed
Description copied from interface:SnapshotSentinel
Get the exception that caused the snapshot to fail, if the snapshot has failed.- Specified by:
getExceptionIfFailed
in interfaceSnapshotSentinel
- Returns:
ForeignException
that caused the snapshot to fail, or null if the snapshot is still in progress or has succeeded
-
rethrowExceptionIfFailed
Description copied from interface:SnapshotSentinel
Rethrow the exception returned bySnapshotSentinel.getExceptionIfFailed()
. If there is no exception this is a no-op.- Specified by:
rethrowExceptionIfFailed
in interfaceSnapshotSentinel
- Throws:
ForeignException
- all exceptions from remote sources are procedure exceptions
-
rethrowException
Description copied from interface:ForeignExceptionSnare
Rethrow an exception currently held by theForeignExceptionSnare
. If there is no exception this is a no-op all exceptions from remote sources are procedure exceptions- Specified by:
rethrowException
in interfaceForeignExceptionSnare
- Throws:
ForeignException
-
hasException
Description copied from interface:ForeignExceptionSnare
Non-exceptional form ofForeignExceptionSnare.rethrowException()
. Checks to see if any process to which the exception checkers is bound has created an error that would cause a failure.- Specified by:
hasException
in interfaceForeignExceptionSnare
- Returns:
- true if there has been an error,false otherwise
-
getException
Description copied from interface:ForeignExceptionSnare
Get the value of the captured exception.- Specified by:
getException
in interfaceForeignExceptionSnare
- Returns:
- the captured foreign exception or null if no exception captured.
-