Package org.red5.server.scheduling
Class JDKSchedulingService
java.lang.Object
org.red5.server.scheduling.JDKSchedulingService
- All Implemented Interfaces:
ISchedulingService,IScopeService,JDKSchedulingServiceMXBean,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean
@ManagedResource(objectName="org.red5.server:name=schedulingService,type=JDKSchedulingService")
public class JDKSchedulingService
extends Object
implements ISchedulingService, JDKSchedulingServiceMXBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Scheduling service that uses JDK ScheduledExecutor as backend.
- Author:
- The Red5 Project, Paul Gregoire (mondain@gmail.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicIntegerprotected ConcurrentMap<String, ScheduledFuture<?>> Storage for job futures keyed by nameprotected ScheduledExecutorServiceService schedulerprotected intFields inherited from interface org.red5.server.api.scheduling.ISchedulingService
BEAN_NAME, SCHEDULED_JOB, SCHEDULING_SERVICE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddScheduledJob(int interval, IScheduledJob job) Schedule a job for periodic execution.addScheduledJobAfterDelay(int interval, IScheduledJob job, int delay) Schedule a job for periodic execution which will start after the specified delay.addScheduledOnceJob(long timeDelta, IScheduledJob job) Schedule a job for single execution in the future.addScheduledOnceJob(Date date, IScheduledJob job) Schedule a job for single execution at a given date.voidConstructs a new JDKSchedulingService.voiddestroy()Getter for job name.Return names of scheduled jobs.intbooleanvoidpauseScheduledJob(String name) Pauses the trigger which initiates job execution.voidremoveScheduledJob(String name) Stop executing a previously scheduled job.voidresumeScheduledJob(String name) Resumes the trigger which initiates job execution.voidsetInterruptOnRemove(boolean interruptOnRemove) voidsetThreadCount(int threadCount)
-
Field Details
-
scheduler
Service scheduler -
threadCount
protected int threadCount -
keyMap
Storage for job futures keyed by name -
jobDetailCounter
-
-
Constructor Details
-
JDKSchedulingService
public JDKSchedulingService()
-
-
Method Details
-
afterPropertiesSet
Constructs a new JDKSchedulingService.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
getThreadCount
public int getThreadCount()- Returns:
- the threadCount
-
setThreadCount
public void setThreadCount(int threadCount) - Parameters:
threadCount- the threadCount to set
-
addScheduledJob
Schedule a job for periodic execution.- Specified by:
addScheduledJobin interfaceISchedulingService- Parameters:
interval- time in milliseconds between two notifications of the jobjob- the job to trigger periodically- Returns:
- the name of the scheduled job
-
addScheduledOnceJob
Schedule a job for single execution at a given date. Please note that the jobs are not saved if Red5 is restarted in the meantime.- Specified by:
addScheduledOnceJobin interfaceISchedulingService- Parameters:
date- date when the job should be executedjob- the job to trigger- Returns:
- the name of the scheduled job
-
addScheduledOnceJob
Schedule a job for single execution in the future. Please note that the jobs are not saved if Red5 is restarted in the meantime.- Specified by:
addScheduledOnceJobin interfaceISchedulingService- Parameters:
timeDelta- time delta in milliseconds from the current datejob- the job to trigger- Returns:
- the name of the scheduled job
-
addScheduledJobAfterDelay
Schedule a job for periodic execution which will start after the specified delay.- Specified by:
addScheduledJobAfterDelayin interfaceISchedulingService- Parameters:
interval- time in milliseconds between two notifications of the jobjob- the job to trigger periodicallydelay- time in milliseconds to pass before first execution.- Returns:
- the name of the scheduled job
-
getJobName
Getter for job name.- Specified by:
getJobNamein interfaceJDKSchedulingServiceMXBean- Returns:
- Job name
-
getScheduledJobNames
Return names of scheduled jobs.- Specified by:
getScheduledJobNamesin interfaceISchedulingService- Specified by:
getScheduledJobNamesin interfaceJDKSchedulingServiceMXBean- Returns:
- list of job names
-
pauseScheduledJob
Pauses the trigger which initiates job execution.- Specified by:
pauseScheduledJobin interfaceISchedulingService- Parameters:
name- name of the job to stop
-
resumeScheduledJob
Resumes the trigger which initiates job execution.- Specified by:
resumeScheduledJobin interfaceISchedulingService- Parameters:
name- name of the job to stop
-
removeScheduledJob
Stop executing a previously scheduled job.- Specified by:
removeScheduledJobin interfaceISchedulingService- Specified by:
removeScheduledJobin interfaceJDKSchedulingServiceMXBean- Parameters:
name- name of the job to stop
-
destroy
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-
isInterruptOnRemove
public boolean isInterruptOnRemove() -
setInterruptOnRemove
public void setInterruptOnRemove(boolean interruptOnRemove)
-