org.apache.hadoop.hbase.executor
Class ExecutorService

java.lang.Object
  extended by org.apache.hadoop.hbase.executor.ExecutorService

public class ExecutorService
extends Object

This is a generic executor service. This component abstracts a threadpool, a queue to which EventHandler.EventTypes can be submitted, and a Runnable that handles the object that is added to the queue.

In order to create a new service, create an instance of this class and then do: instance.startExecutorService("myService");. When done call shutdown().

In order to use the service created above, call submit(EventHandler). Register pre- and post- processing listeners by registering your implementation of EventHandler.EventHandlerListener with registerListener(EventHandler.EventType, EventHandler.EventHandlerListener). Be sure to deregister your listener when done via unregisterListener(EventHandler.EventType).


Nested Class Summary
static class ExecutorService.ExecutorType
          The following is a list of all executor types, both those that run in the master and those that run in the regionserver.
 
Constructor Summary
ExecutorService(String servername)
          Default constructor.
 
Method Summary
 ExecutorService.ExecutorType getExecutorServiceType(EventHandler.EventType type)
          Returns the executor service type (the thread pool instance) for the passed event handler type.
 void registerListener(EventHandler.EventType type, EventHandler.EventHandlerListener listener)
          Subscribe to updates before and after processing instances of EventHandler.EventType.
 void shutdown()
           
 void startExecutorService(ExecutorService.ExecutorType type, int maxThreads)
           
 void submit(EventHandler eh)
           
 EventHandler.EventHandlerListener unregisterListener(EventHandler.EventType type)
          Stop receiving updates before and after processing instances of EventHandler.EventType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutorService

public ExecutorService(String servername)
Default constructor.

Parameters:
servername - Name of the hosting server.
Method Detail

getExecutorServiceType

public ExecutorService.ExecutorType getExecutorServiceType(EventHandler.EventType type)
Returns the executor service type (the thread pool instance) for the passed event handler type.

Parameters:
type - EventHandler type.

shutdown

public void shutdown()

startExecutorService

public void startExecutorService(ExecutorService.ExecutorType type,
                                 int maxThreads)

submit

public void submit(EventHandler eh)

registerListener

public void registerListener(EventHandler.EventType type,
                             EventHandler.EventHandlerListener listener)
Subscribe to updates before and after processing instances of EventHandler.EventType. Currently only one listener per event type.

Parameters:
type - Type of event we're registering listener for
listener - The listener to run.

unregisterListener

public EventHandler.EventHandlerListener unregisterListener(EventHandler.EventType type)
Stop receiving updates before and after processing instances of EventHandler.EventType

Parameters:
type - Type of event we're registering listener for
Returns:
The listener we removed or null if we did not remove it.


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.