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

java.lang.Object
  extended by org.apache.hadoop.hbase.executor.EventHandler
      extended by org.apache.hadoop.hbase.master.handler.CreateTableHandler
          extended by org.apache.hadoop.hbase.master.snapshot.CloneSnapshotHandler
All Implemented Interfaces:
Comparable<Runnable>, Runnable, SnapshotSentinel

@InterfaceAudience.Private
public class CloneSnapshotHandler
extends CreateTableHandler
implements SnapshotSentinel

Handler to Clone a snapshot.

Uses RestoreSnapshotHelper to create a new table with the same content of the specified snapshot.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.executor.EventHandler
EventHandler.EventHandlerListener
 
Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.master.handler.CreateTableHandler
conf, fileSystemManager, hTableDescriptor
 
Fields inherited from class org.apache.hadoop.hbase.executor.EventHandler
eventType, seqids, server, waitingTimeForEvents
 
Constructor Summary
CloneSnapshotHandler(MasterServices masterServices, HBaseProtos.SnapshotDescription snapshot, HTableDescriptor hTableDescriptor)
           
 
Method Summary
protected  void addRegionsToMeta(CatalogTracker ct, List<HRegionInfo> regionInfos)
          Add the specified set of regions to the hbase:meta table.
 void cancel(String why)
          Actively cancel a running snapshot.
protected  void completed(Throwable exception)
          Called after that process() is completed.
 long getCompletionTimestamp()
           
 ForeignException getExceptionIfFailed()
          Get the exception that caused the snapshot to fail, if the snapshot has failed.
 HBaseProtos.SnapshotDescription getSnapshot()
           
protected  List<HRegionInfo> handleCreateHdfsRegions(org.apache.hadoop.fs.Path tableRootDir, TableName tableName)
          Create the on-disk regions, using the tableRootDir provided by the CreateTableHandler.
 boolean isFinished()
          Check to see if the snapshot is finished, where finished may be success or failure.
 CloneSnapshotHandler 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 rethrowExceptionIfFailed()
          Rethrow the exception returned by SnapshotSentinel.getExceptionIfFailed().
 
Methods inherited from class org.apache.hadoop.hbase.master.handler.CreateTableHandler
process, toString
 
Methods inherited from class org.apache.hadoop.hbase.executor.EventHandler
compareTo, getEventType, getInformativeName, getListener, getPriority, getSeqid, handleException, run, setListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CloneSnapshotHandler

public CloneSnapshotHandler(MasterServices masterServices,
                            HBaseProtos.SnapshotDescription snapshot,
                            HTableDescriptor hTableDescriptor)
Method Detail

prepare

public CloneSnapshotHandler prepare()
                             throws NotAllMetaRegionsOnlineException,
                                    TableExistsException,
                                    IOException
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 CreateTableHandler
Returns:
the instance of this class
Throws:
NotAllMetaRegionsOnlineException
TableExistsException
IOException

handleCreateHdfsRegions

protected List<HRegionInfo> handleCreateHdfsRegions(org.apache.hadoop.fs.Path tableRootDir,
                                                    TableName tableName)
                                             throws IOException
Create the on-disk regions, using the tableRootDir provided by the CreateTableHandler. The cloned table will be created in a temp directory, and then the CreateTableHandler will be responsible to add the regions returned by this method to hbase:meta and do the assignment.

Overrides:
handleCreateHdfsRegions in class CreateTableHandler
Parameters:
tableRootDir - directory where the table is being created
tableName - name of the table under construction
Returns:
the list of regions created
Throws:
IOException

addRegionsToMeta

protected void addRegionsToMeta(CatalogTracker ct,
                                List<HRegionInfo> regionInfos)
                         throws IOException
Description copied from class: CreateTableHandler
Add the specified set of regions to the hbase:meta table.

Overrides:
addRegionsToMeta in class CreateTableHandler
Throws:
IOException

completed

protected void completed(Throwable exception)
Description copied from class: CreateTableHandler
Called after that process() is completed.

Overrides:
completed in class CreateTableHandler
Parameters:
exception - null if process() is successful or not null if something has failed.

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

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.

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


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