NodeIDType
- EventType
- KeyType
- The purpose of this class is to store ProtocolTasks and activate
them when a corresponding event arrives.public class ProtocolExecutor<NodeIDType,EventType,KeyType>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static long |
DEFAULT_RESTART_PERIOD |
protected static int |
MAX_TASKS |
protected static int |
MAX_THREADS |
protected static long |
TOO_MANY_TASKS_CHECK_PERIOD |
Constructor and Description |
---|
ProtocolExecutor(Messenger<NodeIDType,?> messenger) |
Modifier and Type | Method and Description |
---|---|
static void |
cancel(ProtocolTask<?,?,?> task) |
static void |
enqueueCancel(java.lang.Object key) |
int |
getActiveCount() |
long |
getCompletedTaskCount() |
static java.util.logging.Logger |
getLogger() |
ProtocolTask<NodeIDType,EventType,KeyType> |
getTask(KeyType key) |
long |
getTaskCount() |
boolean |
handleEvent(ProtocolEvent<EventType,KeyType> event) |
boolean |
isEmpty() |
boolean |
isRunning(KeyType key) |
static void |
main(java.lang.String[] args) |
void |
register(EventType event,
ProtocolTask<NodeIDType,EventType,KeyType> task) |
void |
register(ProtocolTask<NodeIDType,EventType,KeyType> task) |
void |
register(java.util.Set<EventType> events,
ProtocolTask<NodeIDType,EventType,KeyType> task) |
ProtocolTask<?,?,?> |
remove(KeyType key) |
void |
schedule(SchedulableProtocolTask<NodeIDType,EventType,KeyType> actualTask) |
void |
schedule(SchedulableProtocolTask<NodeIDType,EventType,KeyType> actualTask,
long period) |
java.util.concurrent.Future<?> |
scheduleSimple(java.lang.Runnable task,
long initialDelay,
java.util.concurrent.TimeUnit unit) |
java.util.concurrent.Future<?> |
scheduleWithFixedDelay(java.lang.Runnable task,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit) |
int |
size() |
void |
spawn(ProtocolTask<NodeIDType,EventType,KeyType> actualTask) |
boolean |
spawnIfNotRunning(ProtocolTask<NodeIDType,EventType,KeyType> actualTask) |
void |
stop() |
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task) |
java.lang.String |
toString() |
void |
unRegister(EventType event,
ProtocolTask<NodeIDType,EventType,KeyType> task) |
protected static final int MAX_TASKS
protected static final int MAX_THREADS
protected static final long DEFAULT_RESTART_PERIOD
protected static final long TOO_MANY_TASKS_CHECK_PERIOD
public ProtocolExecutor(Messenger<NodeIDType,?> messenger)
messenger
- public static java.util.logging.Logger getLogger()
public void register(EventType event, ProtocolTask<NodeIDType,EventType,KeyType> task)
event
- task
- public void register(java.util.Set<EventType> events, ProtocolTask<NodeIDType,EventType,KeyType> task)
events
- task
- public void register(ProtocolTask<NodeIDType,EventType,KeyType> task)
task
- public void unRegister(EventType event, ProtocolTask<NodeIDType,EventType,KeyType> task)
event
- task
- public void spawn(ProtocolTask<NodeIDType,EventType,KeyType> actualTask)
actualTask
- public boolean spawnIfNotRunning(ProtocolTask<NodeIDType,EventType,KeyType> actualTask)
actualTask
- public java.lang.String toString()
toString
in class java.lang.Object
public void stop()
public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
task
- public java.util.concurrent.Future<?> scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
task
- initialDelay
- period
- unit
- public java.util.concurrent.Future<?> scheduleSimple(java.lang.Runnable task, long initialDelay, java.util.concurrent.TimeUnit unit)
task
- initialDelay
- unit
- public void schedule(SchedulableProtocolTask<NodeIDType,EventType,KeyType> actualTask, long period)
actualTask
- period
- public void schedule(SchedulableProtocolTask<NodeIDType,EventType,KeyType> actualTask)
actualTask
- public ProtocolTask<NodeIDType,EventType,KeyType> getTask(KeyType key)
key
- key
.public ProtocolTask<?,?,?> remove(KeyType key)
key
- public boolean handleEvent(ProtocolEvent<EventType,KeyType> event)
event
- public boolean isEmpty()
public static void enqueueCancel(java.lang.Object key)
key
- public boolean isRunning(KeyType key)
key
- key
is running.public static void cancel(ProtocolTask<?,?,?> task)
task
- public int getActiveCount()
public long getTaskCount()
public long getCompletedTaskCount()
public int size()
public static void main(java.lang.String[] args)
args
-