Package org.opencastproject.execute.impl
Class ExecuteServiceImpl
java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.execute.impl.ExecuteServiceImpl
- All Implemented Interfaces:
ExecuteService,JobProducer,org.osgi.service.cm.ManagedService
public class ExecuteServiceImpl
extends AbstractJobProducer
implements ExecuteService, org.osgi.service.cm.ManagedService
Implements a service that runs CLI commands with MediaPackage elements as arguments
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionList of allowed commands that can be run with an executor.static final StringBundle property specifying which commands can be run with this executorstatic final floatThe approximate load placed on the system by running an execute operationstatic final StringThe key to look for in the service configuration file to override theDEFAULT_EXECUTE_JOB_LOADprotected OrganizationDirectoryServiceThe organization directory serviceprotected SecurityServiceThe security serviceprotected UserDirectoryServiceThe user directory serviceprotected WorkspaceThe workspace serviceFields inherited from class org.opencastproject.job.api.AbstractJobProducer
ACCEPT_JOB_LOADS_EXCEEDING_PROPERTY, acceptJobLoadsExeedingMaxLoad, DEFAULT_ACCEPT_JOB_LOADS_EXCEEDING, executor, jobTypeFields inherited from interface org.opencastproject.execute.api.ExecuteService
COLLECTION, ENDPOINT_NAME, EXEC_FORM_PARAM, INPUT_ELEM_FORM_PARAM, INPUT_FILE_PATTERN, INPUT_MP_FORM_PARAM, JOB_TYPE, LOAD_FORM_PARAM, MP_ID_PATTERN, ORG_ID_PATTERN, OUTPUT_FILE_PATTERN, OUTPUT_NAME_FORM_PARAMETER, PARAMS_FORM_PARAM, TYPE_FORM_PARAMETER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) Activates this component with its properties once all of the collaborating services have been setprotected StringdoProcess(List<String> arguments, MediaPackageElement element, String outFileName, MediaPackageElement.Type expectedType) Does the actual processing, given a mediapackage element (Execute Many WOH)protected StringdoProcess(List<String> arguments, MediaPackage mp, String outFileName, MediaPackageElement.Type expectedType) Does the actual processing, given a mediapackage (Execute Once WOH)execute(String exec, String params, MediaPackageElement inElement, String outFileName, MediaPackageElement.Type expectedType, float load) Execute the operation specified byexecwith the argument string indicated byargs.execute(String exec, String params, MediaPackage mp, String outFileName, MediaPackageElement.Type expectedType, float load) Execute the operation specified byexecwith the argument string indicated byargs.protected OrganizationDirectoryServiceReturns a reference to the organization directory service.protected SecurityServiceReturns a reference to the security serviceprotected ServiceRegistryReturns a reference to the service registry.protected UserDirectoryServiceReturns a reference to the user directory serviceprotected StringAsks the overriding class to process the arguments using the given operation.voidsetOrganizationDirectoryService(OrganizationDirectoryService organizationDirectory) Sets a reference to the organization directory service.voidsetSecurityService(SecurityService securityService) Callback for setting the security service.voidsetServiceRegistry(ServiceRegistry serviceRegistry) Sets the receipt servicevoidsetUserDirectoryService(UserDirectoryService userDirectoryService) Callback for setting the user directory service.voidsetWorkspace(Workspace workspace) Sets a reference to the workspace service.voidupdated(Dictionary properties) Methods inherited from class org.opencastproject.job.api.AbstractJobProducer
acceptJob, countJobs, finallyUpdateJob, getJobType, incident, isReadyToAccept, isReadyToAcceptJobs
-
Field Details
-
securityService
The security service -
userDirectoryService
The user directory service -
organizationDirectoryService
The organization directory service -
workspace
The workspace service -
allowedCommands
List of allowed commands that can be run with an executor. By convention, an empty set doesn't mean any command can be run. An '*' in the service configuration means any command can be executed -
COMMANDS_ALLOWED_PROPERTY
Bundle property specifying which commands can be run with this executor- See Also:
-
DEFAULT_EXECUTE_JOB_LOAD
public static final float DEFAULT_EXECUTE_JOB_LOADThe approximate load placed on the system by running an execute operation- See Also:
-
EXECUTE_JOB_LOAD_KEY
The key to look for in the service configuration file to override theDEFAULT_EXECUTE_JOB_LOAD- See Also:
-
-
Constructor Details
-
ExecuteServiceImpl
public ExecuteServiceImpl()Creates a new instance of the execute service.
-
-
Method Details
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) Activates this component with its properties once all of the collaborating services have been set- Overrides:
activatein classAbstractJobProducer- Parameters:
cc- The component's context, containing the properties used for configuration
-
execute
public Job execute(String exec, String params, MediaPackageElement inElement, String outFileName, MediaPackageElement.Type expectedType, float load) throws ExecuteException, IllegalArgumentException Execute the operation specified byexecwith the argument string indicated byargs. This method may create an output file with the nameoutFileNameand aMediaPackageElementwill be created with theMediaPackageElement.Typeindicated by the argumenttype.- Specified by:
executein interfaceExecuteService- Parameters:
exec- The command to be executed by this methodparams- A string containing the argument list for this command. The special argument "#{in}" will be substituted by the location of the resource represented by theinElementparameter, and "#{out}" by the file name indicated inoutFileName.inElement- AnMediaPackageElementobject to be used as an input to the commandoutFileName- The name of the file the command may possibly create.expectedType- TheMediaPackageElement.Typeof theMediaPackageElementcreated by this command.load- A floating point estimate of the load imposed on the node by executing the command- Returns:
- A
Jobrepresenting the execution of the command. After a successful execution, the {link @Job} payload will contain a serialized mediapackage element. - Throws:
IllegalArgumentException- if the input arguments are incorrectExecuteException- if an internal error occurs- See Also:
-
execute
public Job execute(String exec, String params, MediaPackage mp, String outFileName, MediaPackageElement.Type expectedType, float load) throws ExecuteException Execute the operation specified byexecwith the argument string indicated byargs. This method accepts aMediaPackageas an argument, and elements within that MediaPackage may be referenced in the argument list by using certain placeholders.- Specified by:
executein interfaceExecuteService- Parameters:
exec- The command to be executed by this methodparams- A string containing the argument list for this command. Some special placeholders are allowed, that will be converted into the actual locations of elements in the supplied MediaPackagemp- TheMediaPackagecontainingMediaPackageElementsthat will be used as inputs of the commandoutFileName- The name of the file the command may possibly create.expectedType- TheMediaPackageElement.Typeof theMediaPackageElementcreated by this command.load- A floating point estimate of the load imposed on the node by executing the command- Returns:
- A
Jobrepresenting the execution of the command. After a successful execution, the {link @Job} payload will contain a serialized mediapackage element. - Throws:
ExecuteException- if this method fails to create theJobcorrectly- See Also:
-
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.- Specified by:
processin classAbstractJobProducer- Parameters:
job- the job to process- Returns:
- the operation result
- Throws:
ExecuteException- See Also:
-
doProcess
protected String doProcess(List<String> arguments, MediaPackage mp, String outFileName, MediaPackageElement.Type expectedType) throws ExecuteException Does the actual processing, given a mediapackage (Execute Once WOH)- Parameters:
arguments- The list containing the program and its argumentsmp- MediaPackage used in the operationoutFileName- The name of the resulting fileexpectedType- The expected element type- Returns:
- A
Stringcontaining the command output - Throws:
ExecuteException- if some internal error occurred
-
doProcess
protected String doProcess(List<String> arguments, MediaPackageElement element, String outFileName, MediaPackageElement.Type expectedType) throws ExecuteException Does the actual processing, given a mediapackage element (Execute Many WOH)- Parameters:
arguments- The list containing the program and its argumentsoutFileName- The name of the resulting fileexpectedType- The expected element type- Returns:
- A
Stringcontaining the command output - Throws:
ExecuteException- if some internal error occurred
-
setServiceRegistry
Sets the receipt service- Parameters:
serviceRegistry- the service registry
-
getServiceRegistry
Returns a reference to the service registry.- Specified by:
getServiceRegistryin classAbstractJobProducer- Returns:
- the service registry
- See Also:
-
getSecurityService
Returns a reference to the security service- Specified by:
getSecurityServicein classAbstractJobProducer- Returns:
- the security service
- See Also:
-
setSecurityService
Callback for setting the security service.- Parameters:
securityService- the securityService to set
-
setUserDirectoryService
Callback for setting the user directory service.- Parameters:
userDirectoryService- the userDirectoryService to set
-
getUserDirectoryService
Returns a reference to the user directory service- Specified by:
getUserDirectoryServicein classAbstractJobProducer- Returns:
- the user directory service
- See Also:
-
getOrganizationDirectoryService
Returns a reference to the organization directory service.- Specified by:
getOrganizationDirectoryServicein classAbstractJobProducer- Returns:
- the organization directory service
- See Also:
-
setOrganizationDirectoryService
Sets a reference to the organization directory service.- Parameters:
organizationDirectory- the organization directory
-
setWorkspace
Sets a reference to the workspace service.- Parameters:
workspace-
-
updated
- Specified by:
updatedin interfaceorg.osgi.service.cm.ManagedService- Throws:
org.osgi.service.cm.ConfigurationException
-