@InterfaceAudience.LimitedPrivate(value="Configuration") @InterfaceStability.Unstable public class SnapshotManager extends MasterProcedureManager implements Stoppable
The class provides methods for monitoring in-progress snapshot actions.
Note: Currently there can only be one snapshot being taken at a time over the cluster. This is a simplification in the current implementation.
| Modifier and Type | Field and Description | 
|---|---|
static String | 
HBASE_SNAPSHOT_ENABLED
Enable or disable snapshot support 
 | 
static String | 
ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION
Name of the operation to use in the controller 
 | 
| Constructor and Description | 
|---|
SnapshotManager()  | 
SnapshotManager(MasterServices master,
               MetricsMaster metricsMaster,
               ProcedureCoordinator coordinator,
               ExecutorService pool)
Fully specify all necessary components of a snapshot manager. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
checkSnapshotSupport()
Throws an exception if snapshot operations (take a snapshot, restore, clone) are not supported. 
 | 
void | 
deleteSnapshot(HBaseProtos.SnapshotDescription snapshot)
Delete the specified snapshot 
 | 
void | 
execProcedure(HBaseProtos.ProcedureDescription desc)
Execute a distributed procedure on cluster 
 | 
List<HBaseProtos.SnapshotDescription> | 
getCompletedSnapshots()
Gets the list of all completed snapshots. 
 | 
String | 
getProcedureSignature()
Return the unique signature of the procedure. 
 | 
void | 
initialize(MasterServices master,
          MetricsMaster metricsMaster)
Initialize a globally barriered procedure for master. 
 | 
boolean | 
isProcedureDone(HBaseProtos.ProcedureDescription desc)
Check if the procedure is finished successfully 
 | 
boolean | 
isRestoreDone(HBaseProtos.SnapshotDescription snapshot)
Returns the status of a restore operation. 
 | 
boolean | 
isSnapshotDone(HBaseProtos.SnapshotDescription expected)
Check if the specified snapshot is done 
 | 
boolean | 
isStopped()  | 
void | 
restoreSnapshot(HBaseProtos.SnapshotDescription reqSnapshot)
Restore the specified snapshot 
 | 
void | 
setSnapshotHandlerForTesting(TableName tableName,
                            SnapshotSentinel handler)
Set the handler for the current snapshot 
 | 
void | 
stop(String why)
Stop this service. 
 | 
void | 
takeSnapshot(HBaseProtos.SnapshotDescription snapshot)
Take a snapshot based on the enabled/disabled state of the table. 
 | 
execProcedureWithRetequals, hashCodepublic static final String HBASE_SNAPSHOT_ENABLED
public static final String ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION
public SnapshotManager()
public SnapshotManager(MasterServices master, MetricsMaster metricsMaster, ProcedureCoordinator coordinator, ExecutorService pool) throws IOException, UnsupportedOperationException
master - services for the master where the manager is runningcoordinator - procedure coordinator instance.  exposed for testing.pool - HBase ExecutorServcie instance, exposed for testing.IOExceptionUnsupportedOperationExceptionpublic List<HBaseProtos.SnapshotDescription> getCompletedSnapshots() throws IOException
IOException - File system exceptionpublic void deleteSnapshot(HBaseProtos.SnapshotDescription snapshot) throws SnapshotDoesNotExistException, IOException
snapshot - SnapshotDoesNotExistException - If the specified snapshot does not exist.IOException - For filesystem IOExceptionspublic boolean isSnapshotDone(HBaseProtos.SnapshotDescription expected) throws IOException
expected - IOException - IOException if error from HDFS or RPCUnknownSnapshotException - if snapshot is invalid or does not exist.public void takeSnapshot(HBaseProtos.SnapshotDescription snapshot) throws IOException
snapshot - HBaseSnapshotException - when a snapshot specific exception occurs.IOException - when some sort of generic IO exception occurs.public void setSnapshotHandlerForTesting(TableName tableName, SnapshotSentinel handler)
Exposed for TESTING
tableName - handler - handler the master should use
 TODO get rid of this if possible, repackaging, modify tests.public void restoreSnapshot(HBaseProtos.SnapshotDescription reqSnapshot) throws IOException
reqSnapshot - IOExceptionpublic boolean isRestoreDone(HBaseProtos.SnapshotDescription snapshot) throws IOException
snapshot - IOException - if there was a failure during the restorepublic boolean isStopped()
isStopped in interface StoppableStoppable.stop(String) has been closed.public void checkSnapshotSupport()
                          throws UnsupportedOperationException
UnsupportedOperationException - if snapshot are not supportedpublic void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException
MasterProcedureManagerinitialize in class MasterProcedureManagermaster - Master service interfaceKeeperExceptionIOExceptionUnsupportedOperationExceptionpublic String getProcedureSignature()
ProcedureManagergetProcedureSignature in class ProcedureManagerpublic void execProcedure(HBaseProtos.ProcedureDescription desc) throws IOException
MasterProcedureManagerexecProcedure in class MasterProcedureManagerdesc - Procedure descriptionIOExceptionpublic boolean isProcedureDone(HBaseProtos.ProcedureDescription desc) throws IOException
MasterProcedureManagerisProcedureDone in class MasterProcedureManagerdesc - Procedure descriptionIOException