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 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, EventHandler.EventType
 
Field Summary
protected  org.apache.hadoop.conf.Configuration conf
           
protected  org.apache.hadoop.fs.FileSystem fs
           
protected  MasterServices master
           
protected  MasterMetrics metricsMaster
           
protected  ForeignExceptionDispatcher monitor
           
protected  org.apache.hadoop.fs.Path rootDir
           
protected  HBaseProtos.SnapshotDescription snapshot
           
protected  MonitoredTask status
           
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, MasterMetrics metricsMaster)
           
 
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()
           
 void process()
          Execute the core common portions of taking a snapshot.
 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, 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

metricsMaster

protected final MasterMetrics metricsMaster

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

status

protected final MonitoredTask status
Constructor Detail

TakeSnapshotHandler

public TakeSnapshotHandler(HBaseProtos.SnapshotDescription snapshot,
                           MasterServices masterServices,
                           MasterMetrics metricsMaster)
Parameters:
snapshot - descriptor of the snapshot to take
masterServices - master services provider
Throws:
IOException - on unexpected error
Method Detail

prepare

public TakeSnapshotHandler prepare()
                            throws Exception
Throws:
Exception

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

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

snapshotDisabledRegion

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

Throws:
IOException

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

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 © 2014 The Apache Software Foundation. All Rights Reserved.