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
FieldsModifier and TypeFieldDescriptionprotected final org.apache.hadoop.conf.Configurationprivate booleanstatic final Stringprotected TableDescriptorprivate final longSnapshot creation requires table lock.private static final org.slf4j.Loggerprotected final MasterServicesprotected final MetricsSnapshotprotected final ForeignExceptionDispatcherprotected final org.apache.hadoop.fs.Pathprotected final org.apache.hadoop.fs.FileSystemprotected final org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescriptionprivate final org.apache.hadoop.fs.Pathprotected final SnapshotManagerprotected final SnapshotManifestprotected final TableNameprotected final MonitoredTaskprivate final LockManager.MasterLockprivate final MasterSnapshotVerifierprotected final org.apache.hadoop.fs.Pathprotected final org.apache.hadoop.fs.FileSystemFields inherited from class org.apache.hadoop.hbase.executor.EventHandler
eventType, seqids, server, waitingTimeForEvents -
Constructor Summary
ConstructorsConstructorDescriptionTakeSnapshotHandler(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription snapshot, MasterServices masterServices, SnapshotManager snapshotManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidActively cancel a running snapshot.protected abstract booleanWhen taking snapshot, first we must acquire the exclusive table lock to confirm that there are no ongoing merge/split procedures.longReturns -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.SnapshotDescriptionReturns the description of the snapshot being runbooleanNon-exceptional form ofForeignExceptionSnare.rethrowException().booleanCheck to see if the snapshot is finished, where finished may be success or failure.private TableDescriptorprepare()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.voidprocess()Execute the core common portions of taking a snapshot.voidRethrow an exception currently held by theForeignExceptionSnare.voidRethrow the exception returned bySnapshotSentinel.getExceptionIfFailed().protected voidsnapshotDisabledRegion(RegionInfo regionInfo) Take a snapshot of the specified disabled regionprotected abstract voidsnapshotRegions(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:EventHandlerEvent 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:
preparein 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:
processin classEventHandler
-
snapshotRegions
protected abstract void snapshotRegions(List<Pair<RegionInfo, ServerName>> regions) throws IOException, org.apache.zookeeper.KeeperExceptionSnapshot the specified regions- Throws:
IOExceptionorg.apache.zookeeper.KeeperException
-
snapshotDisabledRegion
Take a snapshot of the specified disabled region- Throws:
IOException
-
cancel
Description copied from interface:SnapshotSentinelActively cancel a running snapshot.- Specified by:
cancelin interfaceSnapshotSentinel- Parameters:
why- Reason for cancellation.
-
isFinished
Description copied from interface:SnapshotSentinelCheck to see if the snapshot is finished, where finished may be success or failure.- Specified by:
isFinishedin interfaceSnapshotSentinel- Returns:
- false if the snapshot is still in progress, true if the snapshot has finished
-
getCompletionTimestamp
Description copied from interface:SnapshotSentinelReturns -1 if the snapshot is in progress, otherwise the completion timestamp.- Specified by:
getCompletionTimestampin interfaceSnapshotSentinel
-
getSnapshot
public org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription getSnapshot()Description copied from interface:SnapshotSentinelReturns the description of the snapshot being run- Specified by:
getSnapshotin interfaceSnapshotSentinel
-
getExceptionIfFailed
Description copied from interface:SnapshotSentinelGet the exception that caused the snapshot to fail, if the snapshot has failed.- Specified by:
getExceptionIfFailedin interfaceSnapshotSentinel- Returns:
ForeignExceptionthat caused the snapshot to fail, or null if the snapshot is still in progress or has succeeded
-
rethrowExceptionIfFailed
Description copied from interface:SnapshotSentinelRethrow the exception returned bySnapshotSentinel.getExceptionIfFailed(). If there is no exception this is a no-op.- Specified by:
rethrowExceptionIfFailedin interfaceSnapshotSentinel- Throws:
ForeignException- all exceptions from remote sources are procedure exceptions
-
rethrowException
Description copied from interface:ForeignExceptionSnareRethrow 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:
rethrowExceptionin interfaceForeignExceptionSnare- Throws:
ForeignException
-
hasException
Description copied from interface:ForeignExceptionSnareNon-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:
hasExceptionin interfaceForeignExceptionSnare- Returns:
- true if there has been an error,false otherwise
-
getException
Description copied from interface:ForeignExceptionSnareGet the value of the captured exception.- Specified by:
getExceptionin interfaceForeignExceptionSnare- Returns:
- the captured foreign exception or null if no exception captured.
-