|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.lens.server.api.events.AsyncEventListener<T>
T - the generic typepublic abstract class AsyncEventListener<T extends LensEvent>
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 | |
|---|---|
protected BlockingQueue<Runnable> |
eventQueue
The event queue. |
protected ThreadPoolExecutor |
processor
The processor. |
| 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 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final ThreadPoolExecutor processor
protected final BlockingQueue<Runnable> eventQueue
| Constructor Detail |
|---|
public AsyncEventListener()
public AsyncEventListener(int poolSize)
poolSize - the pool size
public AsyncEventListener(int poolSize,
int maxQueueSize,
long timeOutSeconds,
boolean isDaemon)
poolSize - size of the event processing poolmaxQueueSize - max size of the event queue, if this is non positive, then the queue is unboundedtimeOutSeconds - time out in seconds when an idle thread is destroyedisDaemon - if the threads used to process should be daemon threads,
if false, then implementation should call stop()
to stop the thread pool| Method Detail |
|---|
public void onEvent(T event)
throws LensException
onEvent in interface LensEventListener<T extends LensEvent>event - the event
LensException - the lens exceptionpublic abstract void process(T event)
event - the eventpublic void stop()
public BlockingQueue<Runnable> getEventQueue()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||