|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.concurrent.AbstractExecutorService java.util.concurrent.ThreadPoolExecutor java.util.concurrent.ScheduledThreadPoolExecutor org.jgroups.util.DefaultTimeScheduler
public class DefaultTimeScheduler
Implementation of TimeScheduler
by extending
ScheduledThreadPoolExecutor
to keep tasks sorted. Tasks will get executed in order
of execution time (by using a DelayQueue
internally.
Nested Class Summary | |
---|---|
protected static class |
DefaultTimeScheduler.RobustRunnable
Class which catches exceptions in run() - https://jira.jboss.org/jira/browse/JGRP-1062 |
protected class |
DefaultTimeScheduler.TaskWrapper<V>
|
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor |
---|
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy |
Nested classes/interfaces inherited from interface org.jgroups.util.TimeScheduler |
---|
TimeScheduler.Task |
Field Summary | |
---|---|
protected static Log |
log
|
Constructor Summary | |
---|---|
DefaultTimeScheduler()
Create a scheduler that executes tasks in dynamically adjustable intervals |
|
DefaultTimeScheduler(int corePoolSize)
|
|
DefaultTimeScheduler(ThreadFactory factory)
|
|
DefaultTimeScheduler(ThreadFactory factory,
int max_threads)
|
Method Summary | |
---|---|
java.lang.String |
dumpTimerTasks()
Returns a list of tasks currently waiting for execution. |
int |
getCurrentThreads()
Returns the current threads in the pool, or -1 if not applicable |
long |
getKeepAliveTime()
Returns the keep alive time (in ms) of the thread pool, or -1 if not applicable |
int |
getMaxThreads()
Returns the configured max threads, or -1 if not applicable |
int |
getMinThreads()
Returns the configured core threads, or -1 if not applicable |
java.util.concurrent.Future<?> |
scheduleWithDynamicInterval(TimeScheduler.Task task)
Schedule a task for execution at varying intervals. |
java.util.concurrent.ScheduledFuture<?> |
scheduleWithFixedDelay(java.lang.Runnable command,
long initialDelay,
long delay,
java.util.concurrent.TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next. |
void |
setKeepAliveTime(long time)
Sets the keep alive time (in ms) of the thread pool. |
void |
setMaxThreads(int size)
Sets the max pool size. |
void |
setMinThreads(int size)
Sets the core pool size. |
void |
setThreadFactory(ThreadFactory factory)
|
int |
size()
Answers the number of tasks currently in the queue. |
void |
stop()
Stop the scheduler if it's running. |
java.lang.String |
toString()
|
Methods inherited from class java.util.concurrent.ScheduledThreadPoolExecutor |
---|
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, remove, schedule, schedule, scheduleAtFixedRate, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, shutdown, shutdownNow, submit, submit, submit |
Methods inherited from class java.util.concurrent.ThreadPoolExecutor |
---|
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated |
Methods inherited from class java.util.concurrent.AbstractExecutorService |
---|
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.jgroups.util.TimeScheduler |
---|
execute, isShutdown, schedule, scheduleAtFixedRate |
Methods inherited from interface java.util.concurrent.ExecutorService |
---|
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated |
Field Detail |
---|
protected static final Log log
Constructor Detail |
---|
public DefaultTimeScheduler()
public DefaultTimeScheduler(ThreadFactory factory)
public DefaultTimeScheduler(ThreadFactory factory, int max_threads)
public DefaultTimeScheduler(int corePoolSize)
Method Detail |
---|
public void setThreadFactory(ThreadFactory factory)
setThreadFactory
in interface TimeScheduler
public java.lang.String dumpTimerTasks()
TimeScheduler
dumpTimerTasks
in interface TimeScheduler
public int getCurrentThreads()
TimeScheduler
getCurrentThreads
in interface TimeScheduler
public int getMinThreads()
TimeScheduler
getMinThreads
in interface TimeScheduler
public void setMinThreads(int size)
TimeScheduler
setMinThreads
in interface TimeScheduler
public int getMaxThreads()
TimeScheduler
getMaxThreads
in interface TimeScheduler
public void setMaxThreads(int size)
TimeScheduler
setMaxThreads
in interface TimeScheduler
public long getKeepAliveTime()
TimeScheduler
getKeepAliveTime
in interface TimeScheduler
public void setKeepAliveTime(long time)
TimeScheduler
setKeepAliveTime
in interface TimeScheduler
public java.util.concurrent.Future<?> scheduleWithDynamicInterval(TimeScheduler.Task task)
org.jgroups.util.DefaultTimeScheduler.Task#nextInterval()
milliseconds. The task is neve done until nextInterval()
return a value <= 0 or the task is cancelled.
scheduleWithDynamicInterval
in interface TimeScheduler
task
- the task to executerelative
- scheduling scheme: true:public java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
TimeScheduler
scheduleWithFixedDelay
in interface java.util.concurrent.ScheduledExecutorService
scheduleWithFixedDelay
in interface TimeScheduler
scheduleWithFixedDelay
in class java.util.concurrent.ScheduledThreadPoolExecutor
command
- the task to executeinitialDelay
- the time to delay first executiondelay
- the delay between the termination of one execution and the commencement of the nextunit
- the time unit of the initialDelay and delay parameters
public int size()
size
in interface TimeScheduler
public void stop()
stop
in interface TimeScheduler
java.lang.InterruptedException
- if interrupted while waiting for thread
to returnpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |