org.apache.hadoop.hbase.executor
Class HBaseEventHandler

java.lang.Object
  extended by org.apache.hadoop.hbase.executor.HBaseEventHandler
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
MasterCloseRegionHandler, MasterOpenRegionHandler

public abstract class HBaseEventHandler
extends Object
implements Runnable

Abstract base class for all HBase event handlers. Subclasses should implement the process() method where the actual handling of the event happens. HBaseEventType is a list of ALL events (which also corresponds to messages - either internal to one component or between components). The event type names specify the component from which the event originated, and the component which is supposed to handle it. Listeners can listen to all the events by implementing the interface HBaseEventHandlerListener, and by registering themselves as a listener. They will be called back before and after the process of every event. TODO: Rename HBaseEvent and HBaseEventType to EventHandler and EventType after ZK refactor as it currently would clash with EventType from ZK and make the code very confusing.


Nested Class Summary
static interface HBaseEventHandler.HBaseEventHandlerListener
          This interface provides hooks to listen to various events received by the queue.
static class HBaseEventHandler.HBaseEventType
          These are a list of HBase events that can be handled by the various HBaseExecutorService's.
 
Field Summary
protected static List<HBaseEventHandler.HBaseEventHandlerListener> eventHandlerListeners
           
protected  HBaseEventHandler.HBaseEventType eventType
           
protected  boolean isRegionServer
           
protected  String serverName
           
 
Constructor Summary
HBaseEventHandler(boolean isRegionServer, String serverName, HBaseEventHandler.HBaseEventType eventType)
          Default base class constructor.
 
Method Summary
 void execute()
          Executes this event object in the caller's thread.
 HBaseExecutorService.HBaseExecutorServiceType getEventHandlerName()
          Return the name for this event type.
 HBaseEventHandler.HBaseEventType getHBEvent()
          Return the event type
 boolean isRegionServer()
           
abstract  void process()
          This method is the main processing loop to be implemented by the various subclasses.
static void registerListener(HBaseEventHandler.HBaseEventHandlerListener listener)
          Subscribe to updates before and after processing events
 void run()
          This is a wrapper around process, used to update listeners before and after events are processed.
 void submit()
          Submits this event object to the correct executor service.
static void unregisterListener(HBaseEventHandler.HBaseEventHandlerListener listener)
          Stop receiving updates before and after processing events
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventType

protected HBaseEventHandler.HBaseEventType eventType

isRegionServer

protected boolean isRegionServer

serverName

protected String serverName

eventHandlerListeners

protected static List<HBaseEventHandler.HBaseEventHandlerListener> eventHandlerListeners
Constructor Detail

HBaseEventHandler

public HBaseEventHandler(boolean isRegionServer,
                         String serverName,
                         HBaseEventHandler.HBaseEventType eventType)
Default base class constructor. TODO: isRegionServer and serverName will go away once we do the HMaster refactor. We will end up passing a ServerStatus which should tell us both the name and if it is a RS or master.

Method Detail

run

public void run()
This is a wrapper around process, used to update listeners before and after events are processed.

Specified by:
run in interface Runnable

process

public abstract void process()
This method is the main processing loop to be implemented by the various subclasses.


registerListener

public static void registerListener(HBaseEventHandler.HBaseEventHandlerListener listener)
Subscribe to updates before and after processing events


unregisterListener

public static void unregisterListener(HBaseEventHandler.HBaseEventHandlerListener listener)
Stop receiving updates before and after processing events


isRegionServer

public boolean isRegionServer()

getEventHandlerName

public HBaseExecutorService.HBaseExecutorServiceType getEventHandlerName()
Return the name for this event type.

Returns:

getHBEvent

public HBaseEventHandler.HBaseEventType getHBEvent()
Return the event type

Returns:

submit

public void submit()
Submits this event object to the correct executor service. This is causes this object to get executed by the correct ExecutorService.


execute

public void execute()
Executes this event object in the caller's thread. This is a synchronous way of executing the event.



Copyright © 2010 Apache Software Foundation. All Rights Reserved.