org.apache.hadoop.hbase.master.handler
Class TableEventHandler

java.lang.Object
  extended by org.apache.hadoop.hbase.executor.EventHandler
      extended by org.apache.hadoop.hbase.master.handler.TableEventHandler
All Implemented Interfaces:
Comparable<Runnable>, Runnable
Direct Known Subclasses:
DeleteTableHandler, ModifyTableHandler, RestoreSnapshotHandler, TableAddFamilyHandler, TableDeleteFamilyHandler, TableModifyFamilyHandler

@InterfaceAudience.Private
public abstract class TableEventHandler
extends EventHandler

Base class for performing operations against tables. Checks on whether the process can go forward are done in constructor rather than later on in process(). The idea is to fail fast rather than later down in an async invocation of process() (which currently has no means of reporting back issues once started).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.executor.EventHandler
EventHandler.EventHandlerListener
 
Field Summary
protected  MasterServices masterServices
           
protected  TableLockManager.TableLock tableLock
           
protected  TableName tableName
           
 
Fields inherited from class org.apache.hadoop.hbase.executor.EventHandler
eventType, seqids, server, waitingTimeForEvents
 
Constructor Summary
TableEventHandler(EventType eventType, TableName tableName, Server server, MasterServices masterServices)
           
 
Method Summary
protected  void completed(Throwable exception)
          Called after that process() is completed.
 HTableDescriptor getTableDescriptor()
          Gets a TableDescriptor from the masterServices.
protected abstract  void handleTableOperation(List<HRegionInfo> regions)
           
 TableEventHandler 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.
protected  void prepareWithTableLock()
          Called from prepare() while holding the table lock.
 void process()
          This method is the main processing loop to be implemented by the various subclasses.
protected  void releaseTableLock()
           
 boolean reOpenAllRegions(List<HRegionInfo> 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

masterServices

protected final MasterServices masterServices

tableName

protected final TableName tableName

tableLock

protected TableLockManager.TableLock tableLock
Constructor Detail

TableEventHandler

public TableEventHandler(EventType eventType,
                         TableName tableName,
                         Server server,
                         MasterServices masterServices)
Method Detail

prepare

public TableEventHandler prepare()
                          throws 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 EventHandler
Returns:
the instance of this class
Throws:
IOException

prepareWithTableLock

protected void prepareWithTableLock()
                             throws IOException
Called from prepare() while holding the table lock. Subclasses can do extra initialization, and not worry about the releasing the table lock.

Throws:
IOException

process

public void process()
Description copied from class: EventHandler
This method is the main processing loop to be implemented by the various subclasses.

Specified by:
process in class EventHandler

releaseTableLock

protected void releaseTableLock()

completed

protected void completed(Throwable exception)
Called after that process() is completed.

Parameters:
exception - null if process() is successful or not null if something has failed.

reOpenAllRegions

public boolean reOpenAllRegions(List<HRegionInfo> regions)
                         throws IOException
Throws:
IOException

getTableDescriptor

public HTableDescriptor getTableDescriptor()
                                    throws FileNotFoundException,
                                           IOException
Gets a TableDescriptor from the masterServices. Can Throw exceptions.

Returns:
Table descriptor for this table
Throws:
TableExistsException
FileNotFoundException
IOException

handleTableOperation

protected abstract void handleTableOperation(List<HRegionInfo> regions)
                                      throws IOException,
                                             org.apache.zookeeper.KeeperException
Throws:
IOException
org.apache.zookeeper.KeeperException


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.