@ManagedResource(description="A job scheduler") public class ThreadPoolJobScheduler extends Object implements JobScheduler, ThreadFactory, org.springframework.jmx.export.naming.SelfNaming, org.springframework.beans.factory.InitializingBean
JobScheduler
interface which schedules and executes jobs
using a ThreadPoolExecutor
.Modifier and Type | Field and Description |
---|---|
protected boolean |
shutdownRequested |
Constructor and Description |
---|
ThreadPoolJobScheduler() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
awaitFreeCapacity()
Wait for free slots for the execution of jobs.
|
void |
execute(ServerJob serverJob)
Execute the given job.
|
int |
getActiveCount()
Get the number of currently active (executing) jobs.
|
long |
getCompletedTaskCount() |
int |
getCorePoolSize() |
ExecutionStrategyFactory |
getExecutionStrategyFactory() |
String |
getInstanceName() |
int |
getMaximumPoolSize() |
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() |
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 |
setExecutionStrategyFactory(ExecutionStrategyFactory executionTypeFactory) |
void |
setInstanceName(String name)
The scheduler's name (used for JMX naming purposes only)
|
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 |
shutdown()
Stop scheduling jobs.
|
void |
start(RequestEndpoint<?> requestEndpoint)
Start scheduling jobs listening on the given request endpoint.
|
public void setConcurrentJobs(int size)
public void setConcurrentJobsPerProcessor(int n)
public void start(RequestEndpoint<?> requestEndpoint) throws Exception
JobScheduler
start
in interface JobScheduler
Exception
public void shutdown()
JobScheduler
shutdown
in interface JobScheduler
public Thread newThread(Runnable r)
newThread
in interface ThreadFactory
@ManagedAttribute(description="Number of actively executing jobs") public int getActiveCount()
JobScheduler
getActiveCount
in interface JobScheduler
@ManagedAttribute(description="Number of completed jobs") public long getCompletedTaskCount()
@ManagedAttribute(description="Maximum number of concurrently executing jobs") public int getMaximumPoolSize()
@ManagedAttribute(description="Number of idle threads in the pool") public int getCorePoolSize()
@ManagedAttribute(description="Priority for executor threads") public int getThreadPriority()
public void setThreadPriority(int threadPriority)
public ObjectName getObjectName() throws MalformedObjectNameException
getObjectName
in interface org.springframework.jmx.export.naming.SelfNaming
MalformedObjectNameException
public void setInstanceName(String name)
JobScheduler
setInstanceName
in interface JobScheduler
@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 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)
public ExecutionStrategyFactory getExecutionStrategyFactory()
public void setExecutionStrategyFactory(ExecutionStrategyFactory executionTypeFactory)
Copyright © 2017 levigo holding gmbh. All rights reserved.