This project has retired. For details please refer to its Attic page.
AsyncEventListener (Lens 2.0.1-beta-incubating API)

org.apache.lens.server.api.events
Class AsyncEventListener<T extends LensEvent>

java.lang.Object
  extended by org.apache.lens.server.api.events.AsyncEventListener<T>
Type Parameters:
T - the generic type
All Implemented Interfaces:
LensEventListener<T>
Direct Known Subclasses:
MetricsServiceImpl.AsyncQueryStatusListener, QueryEndNotifier, QueryExecutionStatisticsGenerator, ResultFormatter, StatisticsLogPartitionHandler, StatisticsStore

public abstract class AsyncEventListener<T extends LensEvent>
extends Object
implements LensEventListener<T>

Event listeners should implement this class if they wish to process events asynchronously. This should be used when event processing can block, or is computationally intensive.


Field Summary
 
Fields inherited from interface org.apache.lens.server.api.events.LensEventListener
HANDLER_METHOD_NAME
 
Constructor Summary
AsyncEventListener()
          Create a single threaded event listener with an unbounded queue, with daemon threads.
AsyncEventListener(int poolSize)
          Create a event listener with poolSize threads with an unbounded queue and daemon threads.
AsyncEventListener(int poolSize, int maxQueueSize, long timeOutSeconds, boolean isDaemon)
          Create an asynchronous event listener which uses a thread poool to process events.
 
Method Summary
 BlockingQueue<Runnable> getEventQueue()
           
 void onEvent(T event)
          Creates a new runnable and calls the process method in it.
abstract  void process(T event)
          Should implement the actual event handling.
 void stop()
          Should be called to stop the event processor thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncEventListener

public AsyncEventListener()
Create a single threaded event listener with an unbounded queue, with daemon threads.


AsyncEventListener

public AsyncEventListener(int poolSize)
Create a event listener with poolSize threads with an unbounded queue and daemon threads.

Parameters:
poolSize - the pool size

AsyncEventListener

public AsyncEventListener(int poolSize,
                          int maxQueueSize,
                          long timeOutSeconds,
                          boolean isDaemon)
Create an asynchronous event listener which uses a thread poool to process events.

Parameters:
poolSize - size of the event processing pool
maxQueueSize - max size of the event queue, if this is non positive, then the queue is unbounded
timeOutSeconds - time out in seconds when an idle thread is destroyed
isDaemon - if the threads used to process should be daemon threads, if false, then implementation should call stop() to stop the thread pool
Method Detail

onEvent

public void onEvent(T event)
             throws LensException
Creates a new runnable and calls the process method in it.

Specified by:
onEvent in interface LensEventListener<T extends LensEvent>
Parameters:
event - the event
Throws:
LensException - the lens exception

process

public abstract void process(T event)
Should implement the actual event handling.

Parameters:
event - the event

stop

public void stop()
Should be called to stop the event processor thread.


getEventQueue

public BlockingQueue<Runnable> getEventQueue()


Copyright © 2014–2015 Apache Software Foundation. All rights reserved.