@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 |
HBASE_SNAPSHOT_SENTINELS_CLEANUP_TIMEOUT_MILLIS
Wait time before removing a finished sentinel from the in-progress map
NOTE: This is used as a safety auto cleanup.
|
static String |
ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION
Name of the operation to use in the controller
|
static long |
SNAPSHOT_SENTINELS_CLEANUP_TIMEOUT_MILLS_DEFAULT |
Constructor and Description |
---|
SnapshotManager() |
Modifier and Type | Method and Description |
---|---|
void |
checkPermissions(HBaseProtos.ProcedureDescription desc,
AccessChecker accessChecker,
User user)
Check for required permissions before executing the procedure.
|
void |
checkSnapshotSupport()
Throws an exception if snapshot operations (take a snapshot, restore, clone) are not supported.
|
void |
deleteSnapshot(SnapshotProtos.SnapshotDescription snapshot)
Delete the specified snapshot
|
void |
execProcedure(HBaseProtos.ProcedureDescription desc)
Execute a distributed procedure on cluster
|
List<SnapshotProtos.SnapshotDescription> |
getCompletedSnapshots()
Gets the list of all completed snapshots.
|
String |
getProcedureSignature()
Return the unique signature of the procedure.
|
ReadWriteLock |
getTakingSnapshotLock() |
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 |
isSnapshotDone(SnapshotProtos.SnapshotDescription expected)
Check if the specified snapshot is done
|
boolean |
isStopped() |
boolean |
isTakingAnySnapshot()
The snapshot operation processing as following:
1. |
boolean |
isTakingSnapshot(TableName tableName)
Check to see if the specified table has a snapshot in progress.
|
long |
restoreOrCloneSnapshot(SnapshotProtos.SnapshotDescription reqSnapshot,
NonceKey nonceKey,
boolean restoreAcl)
Restore or Clone 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(SnapshotProtos.SnapshotDescription snapshot)
Take a snapshot based on the enabled/disabled state of the table.
|
execProcedureWithRet
equals, hashCode
public static final String HBASE_SNAPSHOT_SENTINELS_CLEANUP_TIMEOUT_MILLIS
public static final long SNAPSHOT_SENTINELS_CLEANUP_TIMEOUT_MILLS_DEFAULT
public static final String HBASE_SNAPSHOT_ENABLED
public static final String ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION
public List<SnapshotProtos.SnapshotDescription> getCompletedSnapshots() throws IOException
IOException
- File system exceptionpublic void deleteSnapshot(SnapshotProtos.SnapshotDescription snapshot) throws IOException
snapshot
- SnapshotDoesNotExistException
- If the specified snapshot does not exist.IOException
- For filesystem IOExceptionspublic boolean isSnapshotDone(SnapshotProtos.SnapshotDescription expected) throws IOException
expected
- IOException
- IOException if error from HDFS or RPCUnknownSnapshotException
- if snapshot is invalid or does not exist.public boolean isTakingSnapshot(TableName tableName)
tableName
- name of the table being snapshotted.public ReadWriteLock getTakingSnapshotLock()
public boolean isTakingAnySnapshot()
public void takeSnapshot(SnapshotProtos.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 long restoreOrCloneSnapshot(SnapshotProtos.SnapshotDescription reqSnapshot, NonceKey nonceKey, boolean restoreAcl) throws IOException
reqSnapshot
- nonceKey
- unique identifier to prevent duplicated RPCIOException
public void stop(String why)
Stoppable
public boolean isStopped()
isStopped
in interface Stoppable
Stoppable.stop(String)
has been closed.public void checkSnapshotSupport() throws UnsupportedOperationException
UnsupportedOperationException
- if snapshot are not supportedpublic void initialize(MasterServices master, MetricsMaster metricsMaster) throws org.apache.zookeeper.KeeperException, IOException, UnsupportedOperationException
MasterProcedureManager
initialize
in class MasterProcedureManager
master
- Master service interfaceorg.apache.zookeeper.KeeperException
IOException
UnsupportedOperationException
public String getProcedureSignature()
ProcedureManager
getProcedureSignature
in class ProcedureManager
public void execProcedure(HBaseProtos.ProcedureDescription desc) throws IOException
MasterProcedureManager
execProcedure
in class MasterProcedureManager
desc
- Procedure descriptionIOException
public void checkPermissions(HBaseProtos.ProcedureDescription desc, AccessChecker accessChecker, User user) throws IOException
MasterProcedureManager
checkPermissions
in class MasterProcedureManager
IOException
- if permissions requirements are not met.public boolean isProcedureDone(HBaseProtos.ProcedureDescription desc) throws IOException
MasterProcedureManager
isProcedureDone
in class MasterProcedureManager
desc
- Procedure descriptionIOException
Copyright © 2007–2019 Cloudera. All rights reserved.