org.apache.hadoop.hbase.master.snapshot
Class SnapshotManager

java.lang.Object
  extended by org.apache.hadoop.hbase.procedure.ProcedureManager
      extended by org.apache.hadoop.hbase.procedure.MasterProcedureManager
          extended by org.apache.hadoop.hbase.master.snapshot.SnapshotManager
All Implemented Interfaces:
Stoppable

@InterfaceAudience.LimitedPrivate(value="Configuration")
@InterfaceStability.Unstable
public class SnapshotManager
extends MasterProcedureManager
implements Stoppable

This class manages the procedure of taking and restoring snapshots. There is only one SnapshotManager for the master.

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.


Field Summary
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 Summary
SnapshotManager()
           
SnapshotManager(MasterServices master, MetricsMaster metricsMaster, ProcedureCoordinator coordinator, ExecutorService pool)
          Fully specify all necessary components of a snapshot manager.
 
Method Summary
 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.
 
Methods inherited from class org.apache.hadoop.hbase.procedure.ProcedureManager
equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HBASE_SNAPSHOT_ENABLED

public static final String HBASE_SNAPSHOT_ENABLED
Enable or disable snapshot support

See Also:
Constant Field Values

ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION

public static final String ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION
Name of the operation to use in the controller

See Also:
Constant Field Values
Constructor Detail

SnapshotManager

public SnapshotManager()

SnapshotManager

public SnapshotManager(MasterServices master,
                       MetricsMaster metricsMaster,
                       ProcedureCoordinator coordinator,
                       ExecutorService pool)
                throws IOException,
                       UnsupportedOperationException
Fully specify all necessary components of a snapshot manager. Exposed for testing.

Parameters:
master - services for the master where the manager is running
coordinator - procedure coordinator instance. exposed for testing.
pool - HBase ExecutorServcie instance, exposed for testing.
Throws:
IOException
UnsupportedOperationException
Method Detail

getCompletedSnapshots

public List<HBaseProtos.SnapshotDescription> getCompletedSnapshots()
                                                            throws IOException
Gets the list of all completed snapshots.

Returns:
list of SnapshotDescriptions
Throws:
IOException - File system exception

deleteSnapshot

public void deleteSnapshot(HBaseProtos.SnapshotDescription snapshot)
                    throws SnapshotDoesNotExistException,
                           IOException
Delete the specified snapshot

Parameters:
snapshot -
Throws:
SnapshotDoesNotExistException - If the specified snapshot does not exist.
IOException - For filesystem IOExceptions

isSnapshotDone

public boolean isSnapshotDone(HBaseProtos.SnapshotDescription expected)
                       throws IOException
Check if the specified snapshot is done

Parameters:
expected -
Returns:
true if snapshot is ready to be restored, false if it is still being taken.
Throws:
IOException - IOException if error from HDFS or RPC
UnknownSnapshotException - if snapshot is invalid or does not exist.

takeSnapshot

public void takeSnapshot(HBaseProtos.SnapshotDescription snapshot)
                  throws IOException
Take a snapshot based on the enabled/disabled state of the table.

Parameters:
snapshot -
Throws:
HBaseSnapshotException - when a snapshot specific exception occurs.
IOException - when some sort of generic IO exception occurs.

setSnapshotHandlerForTesting

public void setSnapshotHandlerForTesting(TableName tableName,
                                         SnapshotSentinel handler)
Set the handler for the current snapshot

Exposed for TESTING

Parameters:
tableName -
handler - handler the master should use TODO get rid of this if possible, repackaging, modify tests.

restoreSnapshot

public void restoreSnapshot(HBaseProtos.SnapshotDescription reqSnapshot)
                     throws IOException
Restore the specified snapshot

Parameters:
reqSnapshot -
Throws:
IOException

isRestoreDone

public boolean isRestoreDone(HBaseProtos.SnapshotDescription snapshot)
                      throws IOException
Returns the status of a restore operation. If the in-progress restore is failed throws the exception that caused the failure.

Parameters:
snapshot -
Returns:
false if in progress, true if restore is completed or not requested.
Throws:
IOException - if there was a failure during the restore

stop

public void stop(String why)
Description copied from interface: Stoppable
Stop this service.

Specified by:
stop in interface Stoppable
Parameters:
why - Why we're stopping.

isStopped

public boolean isStopped()
Specified by:
isStopped in interface Stoppable
Returns:
True if Stoppable.stop(String) has been closed.

checkSnapshotSupport

public void checkSnapshotSupport()
                          throws UnsupportedOperationException
Throws an exception if snapshot operations (take a snapshot, restore, clone) are not supported. Called at the beginning of snapshot() and restoreSnapshot() methods.

Throws:
UnsupportedOperationException - if snapshot are not supported

initialize

public void initialize(MasterServices master,
                       MetricsMaster metricsMaster)
                throws org.apache.zookeeper.KeeperException,
                       IOException,
                       UnsupportedOperationException
Description copied from class: MasterProcedureManager
Initialize a globally barriered procedure for master.

Specified by:
initialize in class MasterProcedureManager
Parameters:
master - Master service interface
Throws:
org.apache.zookeeper.KeeperException
IOException
UnsupportedOperationException

getProcedureSignature

public String getProcedureSignature()
Description copied from class: ProcedureManager
Return the unique signature of the procedure. This signature uniquely identifies the procedure. By default, this signature is the string used in the procedure controller (i.e., the root ZK node name for the procedure)

Specified by:
getProcedureSignature in class ProcedureManager

execProcedure

public void execProcedure(HBaseProtos.ProcedureDescription desc)
                   throws IOException
Description copied from class: MasterProcedureManager
Execute a distributed procedure on cluster

Specified by:
execProcedure in class MasterProcedureManager
Parameters:
desc - Procedure description
Throws:
IOException

isProcedureDone

public boolean isProcedureDone(HBaseProtos.ProcedureDescription desc)
                        throws IOException
Description copied from class: MasterProcedureManager
Check if the procedure is finished successfully

Specified by:
isProcedureDone in class MasterProcedureManager
Parameters:
desc - Procedure description
Returns:
true if the specified procedure is finished successfully
Throws:
IOException


Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.