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

java.lang.Object
  extended by org.apache.hadoop.hbase.executor.EventHandler
      extended by org.apache.hadoop.hbase.master.snapshot.TakeSnapshotHandler
All Implemented Interfaces:
Comparable<Runnable>, Runnable, ForeignExceptionSnare, SnapshotSentinel
Direct Known Subclasses:
DisabledTableSnapshotHandler, EnabledTableSnapshotHandler

@InterfaceAudience.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.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.executor.EventHandler
EventHandler.EventHandlerListener
 
Field Summary
protected  org.apache.hadoop.conf.Configuration conf
           
protected  org.apache.hadoop.fs.FileSystem fs
           
protected  HTableDescriptor htd
           
protected  MasterServices master
           
protected  MetricsSnapshot metricsSnapshot
           
protected  ForeignExceptionDispatcher monitor
           
protected  org.apache.hadoop.fs.Path rootDir
           
protected  HBaseProtos.SnapshotDescription snapshot
           
protected  SnapshotManifest snapshotManifest
           
protected  TableName snapshotTable
           
protected  MonitoredTask status
           
protected  TableLockManager.TableLock tableLock
           
protected  TableLockManager tableLockManager
           
protected  org.apache.hadoop.fs.Path workingDir
           
 
Fields inherited from class org.apache.hadoop.hbase.executor.EventHandler
eventType, seqids, server, waitingTimeForEvents
 
Constructor Summary
TakeSnapshotHandler(HBaseProtos.SnapshotDescription snapshot, MasterServices masterServices)
           
 
Method Summary
 void cancel(String why)
          Actively cancel a running snapshot.
 void completeSnapshot(org.apache.hadoop.fs.Path snapshotDir, org.apache.hadoop.fs.Path workingDir, org.apache.hadoop.fs.FileSystem fs)
          Reset the manager to allow another snapshot to proceed
 long getCompletionTimestamp()
           
 ForeignException getException()
          Get the value of the captured exception.
 ForeignException getExceptionIfFailed()
          Get the exception that caused the snapshot to fail, if the snapshot has failed.
 HBaseProtos.SnapshotDescription getSnapshot()
           
 boolean hasException()
          Non-exceptional form of ForeignExceptionSnare.rethrowException().
 boolean isFinished()
          Check to see if the snapshot is finished, where finished may be success or failure.
 TakeSnapshotHandler 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.
protected  void releaseTableLock()
           
 void rethrowException()
          Rethrow an exception currently held by the ForeignExceptionSnare.
 void rethrowExceptionIfFailed()
          Rethrow the exception returned by SnapshotSentinel.getExceptionIfFailed().
protected  void snapshotDisabledRegion(HRegionInfo regionInfo)
          Take a snapshot of the specified disabled region
protected abstract  void snapshotRegions(List<Pair<HRegionInfo,ServerName>> regions)
          Snapshot the specified regions
 
Methods inherited from class org.apache.hadoop.hbase.executor.EventHandler
compareTo, getEventType, getInformativeName, getListener, getPriority, getSeqid, handleException, run, setListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

master

protected final MasterServices master

metricsSnapshot

protected final MetricsSnapshot metricsSnapshot

snapshot

protected final HBaseProtos.SnapshotDescription snapshot

conf

protected final org.apache.hadoop.conf.Configuration conf

fs

protected final org.apache.hadoop.fs.FileSystem fs

rootDir

protected final org.apache.hadoop.fs.Path rootDir

workingDir

protected final org.apache.hadoop.fs.Path workingDir

monitor

protected final ForeignExceptionDispatcher monitor

tableLockManager

protected final TableLockManager tableLockManager

tableLock

protected final TableLockManager.TableLock tableLock

status

protected final MonitoredTask status

snapshotTable

protected final TableName snapshotTable

snapshotManifest

protected final SnapshotManifest snapshotManifest

htd

protected HTableDescriptor htd
Constructor Detail

TakeSnapshotHandler

public TakeSnapshotHandler(HBaseProtos.SnapshotDescription snapshot,
                           MasterServices masterServices)
Parameters:
snapshot - descriptor of the snapshot to take
masterServices - master services provider
Method Detail

prepare

public TakeSnapshotHandler prepare()
                            throws Exception
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 class EventHandler
Returns:
the instance of this class
Throws:
Exception - when something goes wrong

process

public void process()
Execute the core common portions of taking a snapshot. The snapshotRegions(List) call should get implemented for each snapshot flavor.

Specified by:
process in class EventHandler

releaseTableLock

protected void releaseTableLock()

completeSnapshot

public void completeSnapshot(org.apache.hadoop.fs.Path snapshotDir,
                             org.apache.hadoop.fs.Path workingDir,
                             org.apache.hadoop.fs.FileSystem fs)
                      throws SnapshotCreationException,
                             IOException
Reset the manager to allow another snapshot to proceed

Parameters:
snapshotDir - final path of the snapshot
workingDir - directory where the in progress snapshot was built
fs - FileSystem where the snapshot was built
Throws:
SnapshotCreationException - if the snapshot could not be moved
IOException - the filesystem could not be reached

snapshotRegions

protected abstract void snapshotRegions(List<Pair<HRegionInfo,ServerName>> regions)
                                 throws IOException,
                                        org.apache.zookeeper.KeeperException
Snapshot the specified regions

Throws:
IOException
org.apache.zookeeper.KeeperException

snapshotDisabledRegion

protected void snapshotDisabledRegion(HRegionInfo regionInfo)
                               throws IOException
Take a snapshot of the specified disabled region

Throws:
IOException

cancel

public void cancel(String why)
Description copied from interface: SnapshotSentinel
Actively cancel a running snapshot.

Specified by:
cancel in interface SnapshotSentinel
Parameters:
why - Reason for cancellation.

isFinished

public boolean 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 interface SnapshotSentinel
Returns:
false if the snapshot is still in progress, true if the snapshot has finished

getCompletionTimestamp

public long getCompletionTimestamp()
Specified by:
getCompletionTimestamp in interface SnapshotSentinel
Returns:
-1 if the snapshot is in progress, otherwise the completion timestamp.

getSnapshot

public HBaseProtos.SnapshotDescription getSnapshot()
Specified by:
getSnapshot in interface SnapshotSentinel
Returns:
the description of the snapshot being run

getExceptionIfFailed

public ForeignException getExceptionIfFailed()
Description copied from interface: SnapshotSentinel
Get the exception that caused the snapshot to fail, if the snapshot has failed.

Specified by:
getExceptionIfFailed in interface SnapshotSentinel
Returns:
ForeignException that caused the snapshot to fail, or null if the snapshot is still in progress or has succeeded

rethrowExceptionIfFailed

public void rethrowExceptionIfFailed()
                              throws ForeignException
Description copied from interface: SnapshotSentinel
Rethrow the exception returned by SnapshotSentinel.getExceptionIfFailed(). If there is no exception this is a no-op.

Specified by:
rethrowExceptionIfFailed in interface SnapshotSentinel
Throws:
ForeignException - all exceptions from remote sources are procedure exceptions

rethrowException

public void rethrowException()
                      throws ForeignException
Description copied from interface: ForeignExceptionSnare
Rethrow an exception currently held by the ForeignExceptionSnare. If there is no exception this is a no-op

Specified by:
rethrowException in interface ForeignExceptionSnare
Throws:
ForeignException - all exceptions from remote sources are procedure exceptions

hasException

public boolean hasException()
Description copied from interface: ForeignExceptionSnare
Non-exceptional form of ForeignExceptionSnare.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 interface ForeignExceptionSnare
Returns:
true if there has been an error,false otherwise

getException

public ForeignException getException()
Description copied from interface: ForeignExceptionSnare
Get the value of the captured exception.

Specified by:
getException in interface ForeignExceptionSnare
Returns:
the captured foreign exception or null if no exception captured.


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