@ManagedResource(description="A job scheduler") public class ThreadPoolJobScheduler extends ThreadPoolExecutor implements JobScheduler, ThreadFactory, org.springframework.jmx.export.naming.SelfNaming, org.springframework.beans.factory.InitializingBean
JobScheduler
interface which schedules and executes jobs
using a ThreadPoolExecutor
.ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Modifier and Type | Field and Description |
---|---|
protected boolean |
shutdownRequested |
Constructor and Description |
---|
ThreadPoolJobScheduler() |
Modifier and Type | Method and Description |
---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
void |
afterPropertiesSet() |
void |
awaitFreeCapacity()
Wait for free slots for the execution of jobs.
|
protected void |
beforeExecute(Thread t,
Runnable r) |
void |
execute(ServerJob serverJob)
Execute the given job.
|
int |
getActiveCount()
Get the number of currently active (executing) jobs.
|
long |
getCompletedTaskCount() |
int |
getCorePoolSize() |
String |
getInstanceName() |
long |
getMaximumCommunicationTimeout() |
int |
getMaximumPoolSize() |
long |
getMaximumProcessingTimeout() |
NodeWorkerFactory |
getNodeWorkerFactory()
The
NodeWorkerFactory which is responsible to instantiate
NodeWorker s from a given Node for jobs that run on jadice server. |
ObjectName |
getObjectName() |
ServerStatistics |
getStatisticsRecorder() |
File |
getTempDir()
Get the directory to be used for temporary files for this instance.
|
String |
getTempDirName() |
TempFileReaper |
getTempFileReaper()
Get a reaper for temporary
File s |
int |
getThreadPriority() |
WorkerThreadReaper |
getWorkerThreadReaper()
Get the reaper for worker
Thread s |
boolean |
isRunning()
Return whether the scheduler is running.
|
Thread |
newThread(Runnable r) |
void |
notifyStateChanged(ServerJob serverJob,
Job.State state)
|
void |
setConcurrentJobs(int size) |
void |
setConcurrentJobsPerProcessor(int n) |
void |
setInstanceName(String name)
The scheduler's name (used for JMX naming purposes only)
|
void |
setMaximumCommunicationTimeout(long maximumCommunicationTimeout) |
void |
setMaximumProcessingTimeout(long maximumProcessingTimeout) |
void |
setNodeWorkerFactory(NodeWorkerFactory workerFactory) |
void |
setStatisticsRecorder(ServerStatistics statistics) |
void |
setTempDir(File tempDir) |
void |
setTempDirName(String tempDir) |
void |
setTempFileReaper(TempFileReaper tempFileReaper) |
void |
setThreadPriority(int threadPriority) |
void |
setWorkerThreadReaper(WorkerThreadReaper workerThreadReaper) |
void |
shutdown()
Stop scheduling jobs.
|
void |
start(javax.jms.QueueConnectionFactory factory,
String queueName,
StreamTransportFactory transport)
Start scheduling jobs listening on the given queue.
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, getKeepAliveTime, getLargestPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdownNow, terminated, toString
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
public void setConcurrentJobs(int size)
public void setConcurrentJobsPerProcessor(int n)
public void start(javax.jms.QueueConnectionFactory factory, String queueName, StreamTransportFactory transport) throws Exception
JobScheduler
start
in interface JobScheduler
Exception
public void shutdown()
JobScheduler
shutdown
in interface JobScheduler
shutdown
in interface ExecutorService
shutdown
in class ThreadPoolExecutor
public Thread newThread(Runnable r)
newThread
in interface ThreadFactory
protected void beforeExecute(Thread t, Runnable r)
beforeExecute
in class ThreadPoolExecutor
protected void afterExecute(Runnable r, Throwable t)
afterExecute
in class ThreadPoolExecutor
@ManagedAttribute(description="Number of actively executing jobs") public int getActiveCount()
JobScheduler
getActiveCount
in interface JobScheduler
getActiveCount
in class ThreadPoolExecutor
@ManagedAttribute(description="Number of completed jobs") public long getCompletedTaskCount()
getCompletedTaskCount
in class ThreadPoolExecutor
@ManagedAttribute(description="Maximum number of concurrently executing jobs") public int getMaximumPoolSize()
getMaximumPoolSize
in class ThreadPoolExecutor
@ManagedAttribute(description="Number of idle threads in the pool") public int getCorePoolSize()
getCorePoolSize
in class ThreadPoolExecutor
@ManagedAttribute(description="Priority for executor threads") public int getThreadPriority()
public void setThreadPriority(int threadPriority)
public ObjectName getObjectName()
getObjectName
in interface org.springframework.jmx.export.naming.SelfNaming
public void setInstanceName(String name)
JobScheduler
setInstanceName
in interface JobScheduler
public long getMaximumCommunicationTimeout()
public void setMaximumCommunicationTimeout(long maximumCommunicationTimeout)
public long getMaximumProcessingTimeout()
public void setMaximumProcessingTimeout(long maximumProcessingTimeout)
@ManagedAttribute public boolean isRunning()
JobScheduler
isRunning
in interface JobScheduler
true
iff the scheduler is runningpublic void awaitFreeCapacity()
JobScheduler
awaitFreeCapacity
in interface JobScheduler
public String getInstanceName()
getInstanceName
in interface JobScheduler
public void execute(ServerJob serverJob)
JobScheduler
execute
in interface JobScheduler
public File getTempDir()
JobScheduler
getTempDir
in interface JobScheduler
public void setTempDir(File tempDir)
public String getTempDirName()
public void setTempDirName(String tempDir)
public void notifyStateChanged(ServerJob serverJob, Job.State state)
JobScheduler
Job.State
of a
ServerJob
has changed. No mission critical component must rely on this information.notifyStateChanged
in interface JobScheduler
serverJob
- The job that has changed the statestate
- the new statepublic WorkerThreadReaper getWorkerThreadReaper()
JobScheduler
Thread
sgetWorkerThreadReaper
in interface JobScheduler
WorkerThreadReaper
public void setWorkerThreadReaper(WorkerThreadReaper workerThreadReaper)
public TempFileReaper getTempFileReaper()
JobScheduler
File
sgetTempFileReaper
in interface JobScheduler
TempFileReaper
public void setTempFileReaper(TempFileReaper tempFileReaper)
public NodeWorkerFactory getNodeWorkerFactory()
NodeWorkerFactory
which is responsible to instantiate
NodeWorker
s from a given Node
for jobs that run on jadice server.NodeWorkerFactory
to usepublic void setNodeWorkerFactory(NodeWorkerFactory workerFactory)
public ServerStatistics getStatisticsRecorder()
public void setStatisticsRecorder(ServerStatistics statistics)
Copyright © 2016 levigo holding gmbh. All rights reserved.