Package org.opencastproject.job.api
Class AbstractJobProducer
java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
- All Implemented Interfaces:
JobProducer
- Direct Known Subclasses:
AbstractCoverImageService,AbstractDistributionService,AmberscriptTranscriptionService,AnimateServiceImpl,AssetManagerJobProducer,CaptionServiceImpl,ComposerServiceImpl,ConfigurablePublicationServiceImpl,CropServiceImpl,ExecuteServiceImpl,GoogleSpeechTranscriptionService,IBMWatsonTranscriptionService,IngestDownloadServiceImpl,IngestServiceImpl,MediaInspectionServiceImpl,MicrosoftAzureTranscriptionService,OaiPmhPublicationServiceImpl,OsgiAbstractJobProducer,SearchServiceImpl,SilenceDetectionServiceImpl,SoxServiceImpl,SpeechToTextServiceImpl,TextAnalyzerServiceImpl,TimelinePreviewsServiceImpl,VideoEditorServiceImpl,VideoGridServiceImpl,VideoSegmenterServiceImpl,WaveformServiceImpl,YouTubeV3PublicationServiceImpl
This class serves as a convenience for services that implement the
JobProducer api to deal with handling long
running, asynchronous operations.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe key to look for in the service configuration file to override theDEFAULT_ACCEPT_JOB_LOADS_EXCEEDINGprotected booleanWhether to accept a job whose load exceeds the host’s max loadstatic final booleanThe default value whether to accept a job whose load exceeds the host’s max loadprotected ExecutorServiceTo enable threading when dispatching jobsprotected StringThe types of job that this producer can handle -
Constructor Summary
ConstructorsConstructorDescriptionAbstractJobProducer(String jobType) Creates a new abstract job producer for jobs of the given type. -
Method Summary
Modifier and TypeMethodDescriptionvoidAsks the job producer to handle the given job using the provided operation and list of arguments.voidactivate(org.osgi.service.component.ComponentContext cc) OSGI activate method.longcountJobs(Job.Status status) Get the number of jobs in a current status on all nodes.protected voidfinallyUpdateJob(Job job) Private utility to update and optionally fail job, called from a finally block.The type of jobs that this producer creates.protected abstract OrganizationDirectoryServiceReturns a reference to the organization directory service.protected abstract SecurityServiceReturns a reference to the security serviceprotected abstract ServiceRegistryReturns a reference to the service registry.protected abstract UserDirectoryServiceReturns a reference to the user directory serviceincident()Shorthand forgetServiceRegistry().incident()booleanisReadyToAccept(Job job) Whether the job can be accepted.booleanisReadyToAcceptJobs(String operation) Whether new jobs can be accepted in general.protected abstract StringAsks the overriding class to process the arguments using the given operation.
-
Field Details
-
DEFAULT_ACCEPT_JOB_LOADS_EXCEEDING
public static final boolean DEFAULT_ACCEPT_JOB_LOADS_EXCEEDINGThe default value whether to accept a job whose load exceeds the host’s max load- See Also:
-
ACCEPT_JOB_LOADS_EXCEEDING_PROPERTY
The key to look for in the service configuration file to override theDEFAULT_ACCEPT_JOB_LOADS_EXCEEDING- See Also:
-
acceptJobLoadsExeedingMaxLoad
protected boolean acceptJobLoadsExeedingMaxLoadWhether to accept a job whose load exceeds the host’s max load -
jobType
The types of job that this producer can handle -
executor
To enable threading when dispatching jobs
-
-
Constructor Details
-
AbstractJobProducer
Creates a new abstract job producer for jobs of the given type.- Parameters:
jobType- the job type
-
-
Method Details
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) OSGI activate method.- Parameters:
cc- OSGI component context
-
getJobType
The type of jobs that this producer creates.- Specified by:
getJobTypein interfaceJobProducer- Returns:
- the job type
- See Also:
-
countJobs
Get the number of jobs in a current status on all nodes.- Specified by:
countJobsin interfaceJobProducer- Returns:
- Number of jobs in this state
- Throws:
ServiceRegistryException- if an error occurs while communicating with the backing data source- See Also:
-
acceptJob
Asks the job producer to handle the given job using the provided operation and list of arguments. The implementation of this method must be asynchronous if the processing takes more than a few seconds.- Specified by:
acceptJobin interfaceJobProducer- Parameters:
job- the job being dispatched- Throws:
ServiceRegistryException- if the producer was unable to start work as requested- See Also:
-
isReadyToAcceptJobs
Whether new jobs can be accepted in general.- Specified by:
isReadyToAcceptJobsin interfaceJobProducer- Parameters:
operation- operation- Returns:
- whether the service is ready to accept jobs
- Throws:
ServiceRegistryException- if the producer was unable to start work as requested- See Also:
-
isReadyToAccept
Whether the job can be accepted.- Specified by:
isReadyToAcceptin interfaceJobProducer- Parameters:
job- the job being dispatched- Returns:
- whether the service is ready to accept the job
- Throws:
ServiceRegistryException- if the producer was unable to start work as requestedUndispatchableJobException- if the job will never be accepted because it is unacceptable- See Also:
-
finallyUpdateJob
Private utility to update and optionally fail job, called from a finally block.- Parameters:
job- to be updated, may be null
-
incident
Shorthand forgetServiceRegistry().incident() -
getServiceRegistry
Returns a reference to the service registry.- Returns:
- the service registry
-
getSecurityService
Returns a reference to the security service- Returns:
- the security service
-
getUserDirectoryService
Returns a reference to the user directory service- Returns:
- the user directory service
-
getOrganizationDirectoryService
Returns a reference to the organization directory service.- Returns:
- the organization directory service
-
process
Asks the overriding class to process the arguments using the given operation. The result will be added to the associated job as the payload.- Parameters:
job- the job to process- Returns:
- the operation result
- Throws:
Exception
-