org.apache.hadoop.hbase.executor
Class ExecutorService

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

@InterfaceAudience.Private
public class ExecutorService
extends Object

This is a generic executor service. This component abstracts a threadpool, a queue to which 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(EventType, EventHandler.EventHandlerListener). Be sure to deregister your listener when done via unregisterListener(EventType).


Nested Class Summary
static class ExecutorService.ExecutorStatus
          A snapshot of the status of a particular executor.
static class ExecutorService.RunningEventStatus
          The status of a particular event that is in the middle of being handled by an executor.
 
Constructor Summary
ExecutorService(String servername)
          Default constructor.
 
Method Summary
 Map<String,ExecutorService.ExecutorStatus> getAllExecutorStatuses()
           
 void registerListener(EventType type, EventHandler.EventHandlerListener listener)
          Subscribe to updates before and after processing instances of EventType.
 void shutdown()
           
 void startExecutorService(ExecutorType type, int maxThreads)
           
 void submit(EventHandler eh)
           
 EventHandler.EventHandlerListener unregisterListener(EventType type)
          Stop receiving updates before and after processing instances of 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

shutdown

public void shutdown()

startExecutorService

public void startExecutorService(ExecutorType type,
                                 int maxThreads)

submit

public void submit(EventHandler eh)

registerListener

public void registerListener(EventType type,
                             EventHandler.EventHandlerListener listener)
Subscribe to updates before and after processing instances of 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(EventType type)
Stop receiving updates before and after processing instances of EventType

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

getAllExecutorStatuses

public Map<String,ExecutorService.ExecutorStatus> getAllExecutorStatuses()


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