@InterfaceAudience.Private public class ExecutorService extends Object
EventType
s 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)
.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ExecutorService.Executor
Executor instance.
|
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.
|
(package private) static class |
ExecutorService.TrackingThreadPoolExecutor
A subclass of ThreadPoolExecutor that keeps track of the Runnables that
are executing at any given point in time.
|
Modifier and Type | Field and Description |
---|---|
private ConcurrentHashMap<EventType,EventHandler.EventHandlerListener> |
eventHandlerListeners |
private ConcurrentHashMap<String,ExecutorService.Executor> |
executorMap |
private static org.apache.commons.logging.Log |
LOG |
private String |
servername |
Constructor and Description |
---|
ExecutorService(String servername)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
Map<String,ExecutorService.ExecutorStatus> |
getAllExecutorStatuses() |
(package private) ExecutorService.Executor |
getExecutor(ExecutorType type) |
(package private) ExecutorService.Executor |
getExecutor(String name) |
(package private) boolean |
isExecutorServiceRunning(String name) |
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) |
(package private) void |
startExecutorService(String name,
int maxThreads)
Start an executor service with a given name.
|
void |
submit(EventHandler eh) |
EventHandler.EventHandlerListener |
unregisterListener(EventType type)
Stop receiving updates before and after processing instances of
EventType |
private static final org.apache.commons.logging.Log LOG
private final ConcurrentHashMap<String,ExecutorService.Executor> executorMap
private ConcurrentHashMap<EventType,EventHandler.EventHandlerListener> eventHandlerListeners
private final String servername
public ExecutorService(String servername)
servername
- Name of the hosting server.void startExecutorService(String name, int maxThreads)
name
- Name of the service to start.boolean isExecutorServiceRunning(String name)
public void shutdown()
ExecutorService.Executor getExecutor(ExecutorType type)
ExecutorService.Executor getExecutor(String name)
public void startExecutorService(ExecutorType type, int maxThreads)
public void submit(EventHandler eh)
public void registerListener(EventType type, EventHandler.EventHandlerListener listener)
EventType
. Currently only one listener per
event type.type
- Type of event we're registering listener forlistener
- The listener to run.public EventHandler.EventHandlerListener unregisterListener(EventType type)
EventType
type
- Type of event we're registering listener forpublic Map<String,ExecutorService.ExecutorStatus> getAllExecutorStatuses()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.