Class DownloadDistributionServiceImpl
java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.distribution.api.AbstractDistributionService
org.opencastproject.distribution.download.DownloadDistributionServiceImpl
- All Implemented Interfaces:
DistributionService,DownloadDistributionService,JobProducer,org.osgi.service.cm.ManagedService
public class DownloadDistributionServiceImpl
extends AbstractDistributionService
implements DistributionService, DownloadDistributionService, org.osgi.service.cm.ManagedService
Distributes media to the local media delivery directory.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatThe load on the system introduced by creating a distribute jobstatic final floatThe load on the system introduced by creating a retract jobstatic final StringThe key to look for in the service configuration file to override theDEFAULT_DISTRIBUTE_JOB_LOADstatic final StringReceipt typestatic final StringThe key to look for in the service configuration file to override theDEFAULT_RETRACT_JOB_LOADFields inherited from class org.opencastproject.distribution.api.AbstractDistributionService
distributionChannel, distributionDirectory, organizationDirectoryService, securityService, serviceRegistry, serviceUrl, trustedHttpClient, userDirectoryService, workspaceFields 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.distribution.api.DistributionService
CONFIG_KEY_STORE_TYPE, JOB_TYPE_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of the download distribution service. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) Activate method for this OSGi service implementation.checkDistributeHLSElement(Track element, boolean checkAvailability) distribute(String channelId, MediaPackage mediapackage, String elementId) Distribute a media package element.distribute(String channelId, MediaPackage mediapackage, String elementId, boolean checkAvailability) distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) distributeElement(String channelId, MediaPackage mediapackage, MediaPackageElement element, boolean checkAvailability, boolean preserveReference) Distribute a Mediapackage element to the download distribution service.distributeElements(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) Distribute Mediapackage elements to the download distribution service.distributeElements(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) Distribute Mediapackage elements to the download distribution service.distributeSync(String channelId, MediaPackage mediapackage, String elementId) Distributes a media package element synchronously, bypassing the Opencast job system.distributeSync(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) Distributes the given elements synchronously.distributeSync(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) protected FilegetDistributionFile(String channelId, MediaPackage mp, MediaPackageElement element) Gets the destination file to copy the contents of a mediapackage element.Returns the distribution type for this service.protected URIgetDistributionUri(String channelId, String mediaPackageId, MediaPackageElement element) Gets the URI for the element to be distributed.protected FilegetMediaPackageDirectory(String channelId, MediaPackage mp) Gets the directory containing the distributed files for this mediapackage.protected StringAsks the overriding class to process the arguments using the given operation.retract(String channelId, MediaPackage mediapackage, String elementId) Retract a media package element from the distribution channel.retract(String channelId, MediaPackage mediapackage, Set<String> elementIds) protected MediaPackageElementretractElement(String channelId, MediaPackage mediapackage, MediaPackageElement element) Retract a media package element from the distribution channel.protected MediaPackageElement[]retractElements(String channelId, MediaPackage mediapackage, Set<String> elementIds) Retract a media package element from the distribution channel.retractSync(String channelId, MediaPackage mediapackage, String elementId) Retract a media package element from the distribution channel synchronously, bypassing the Opencast job system.retractSync(String channelId, MediaPackage mediapackage, Set<String> elementIds) Retracts the given elements synchronously.voidsetOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService) Sets a reference to the organization directory service.voidsetSecurityService(SecurityService securityService) Callback for setting the security service.voidsetServiceRegistry(ServiceRegistry serviceRegistry) Callback for the OSGi environment to set the service registry reference.voidsetTrustedHttpClient(TrustedHttpClient trustedHttpClient) Callback for the OSGi environment to set the trusted http clientreference.setUpHLSElementforDistribution(String channelId, MediaPackage mediapackage, Track element, boolean preserveReference) voidsetUserDirectoryService(UserDirectoryService userDirectoryService) Callback for setting the user directory service.voidsetWorkspace(Workspace workspace) Callback for the OSGi environment to set the workspace reference.voidupdated(Dictionary properties) Methods inherited from class org.opencastproject.distribution.api.AbstractDistributionService
getOrganizationDirectoryService, getSecurityService, getServiceRegistry, getTrustedHttpClient, getUserDirectoryServiceMethods inherited from class org.opencastproject.job.api.AbstractJobProducer
acceptJob, countJobs, finallyUpdateJob, getJobType, incident, isReadyToAccept, isReadyToAcceptJobs
-
Field Details
-
JOB_TYPE
Receipt type- See Also:
-
DEFAULT_DISTRIBUTE_JOB_LOAD
public static final float DEFAULT_DISTRIBUTE_JOB_LOADThe load on the system introduced by creating a distribute job- See Also:
-
DEFAULT_RETRACT_JOB_LOAD
public static final float DEFAULT_RETRACT_JOB_LOADThe load on the system introduced by creating a retract job- See Also:
-
DISTRIBUTE_JOB_LOAD_KEY
The key to look for in the service configuration file to override theDEFAULT_DISTRIBUTE_JOB_LOAD- See Also:
-
RETRACT_JOB_LOAD_KEY
The key to look for in the service configuration file to override theDEFAULT_RETRACT_JOB_LOAD- See Also:
-
-
Constructor Details
-
DownloadDistributionServiceImpl
public DownloadDistributionServiceImpl()Creates a new instance of the download distribution service.
-
-
Method Details
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) Activate method for this OSGi service implementation.- Overrides:
activatein classAbstractJobProducer- Parameters:
cc- the OSGi component context
-
getDistributionType
Description copied from interface:DistributionServiceReturns the distribution type for this service. This type should be unique within an Opencast instance, and is used to select where file distribution happens.- Specified by:
getDistributionTypein interfaceDistributionService- Returns:
- The distribution type. A string like "download", or "streaming"
-
distribute
public Job distribute(String channelId, MediaPackage mediapackage, String elementId) throws DistributionException, MediaPackageException Description copied from interface:DistributionServiceDistribute a media package element.- Specified by:
distributein interfaceDistributionService- Parameters:
mediapackage- the media packageelementId- the element in the media package to distribute- Returns:
- The job
- Throws:
DistributionException- if there was a problem distributing the mediaMediaPackageException- if there was a problem with the mediapackage element
-
distribute
public Job distribute(String channelId, MediaPackage mediapackage, String elementId, boolean checkAvailability) throws DistributionException, MediaPackageException - Specified by:
distributein interfaceDownloadDistributionService- Throws:
DistributionExceptionMediaPackageException
-
distribute
public Job distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws DistributionException, MediaPackageException - Specified by:
distributein interfaceDownloadDistributionService- Throws:
DistributionExceptionMediaPackageException
-
distribute
public Job distribute(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) throws DistributionException, MediaPackageException - Specified by:
distributein interfaceDownloadDistributionService- Throws:
DistributionExceptionMediaPackageException
-
distributeElements
public MediaPackageElement[] distributeElements(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws DistributionException Distribute Mediapackage elements to the download distribution service.- Parameters:
channelId- # The id of the publication channel to be distributed to.mediapackage- The media package that contains the elements to be distributed.elementIds- The ids of the elements that should be distributed contained within the media package.checkAvailability- Check the availability of the distributed element via http.- Returns:
- A reference to the MediaPackageElements that have been distributed.
- Throws:
DistributionException- Thrown if the parent directory of the MediaPackageElement cannot be created, if the MediaPackageElement cannot be copied or another unexpected exception occurs.
-
distributeElements
public MediaPackageElement[] distributeElements(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) throws DistributionException Distribute Mediapackage elements to the download distribution service.- Parameters:
channelId- # The id of the publication channel to be distributed to.mediapackage- The media package that contains the elements to be distributed.elementIds- The ids of the elements that should be distributed contained within the media package.checkAvailability- Check the availability of the distributed element via http.preserveReference- copy actual Reference to the new distributed element- Returns:
- A reference to the MediaPackageElements that have been distributed.
- Throws:
DistributionException- Thrown if the parent directory of the MediaPackageElement cannot be created, if the MediaPackageElement cannot be copied or another unexpected exception occurs.
-
distributeElement
public MediaPackageElement distributeElement(String channelId, MediaPackage mediapackage, MediaPackageElement element, boolean checkAvailability, boolean preserveReference) throws DistributionException Distribute a Mediapackage element to the download distribution service.- Parameters:
channelId- # The id of the publication channel to be distributed to.mediapackage- The media package that contains the element to be distributed.element- The the element that should be distributed contained within the media package.checkAvailability- Check the availability of the distributed element via http.preserveReference- Copy existing Track-Reference to the new distributed Track- Returns:
- A reference to the MediaPackageElement that has been distributed.
- Throws:
DistributionException- Thrown if the parent directory of the MediaPackageElement cannot be created, if the MediaPackageElement cannot be copied or another unexpected exception occurs.
-
setUpHLSElementforDistribution
public Track setUpHLSElementforDistribution(String channelId, MediaPackage mediapackage, Track element, boolean preserveReference) throws DistributionException - Throws:
DistributionException
-
checkDistributeHLSElement
public Track checkDistributeHLSElement(Track element, boolean checkAvailability) throws DistributionException - Throws:
DistributionException
-
retract
public Job retract(String channelId, MediaPackage mediapackage, String elementId) throws DistributionException Description copied from interface:DistributionServiceRetract a media package element from the distribution channel.- Specified by:
retractin interfaceDistributionService- Parameters:
mediapackage- the media packageelementId- the media package element to retract- Throws:
DistributionException- if there was a problem retracting the mediapackage
-
retract
public Job retract(String channelId, MediaPackage mediapackage, Set<String> elementIds) throws DistributionException - Specified by:
retractin interfaceDownloadDistributionService- Throws:
DistributionException
-
distributeSync
public List<MediaPackageElement> distributeSync(String channelId, MediaPackage mediapackage, String elementId) throws DistributionException, MediaPackageException Description copied from interface:DistributionServiceDistributes a media package element synchronously, bypassing the Opencast job system.- Specified by:
distributeSyncin interfaceDistributionService- Parameters:
mediapackage- the media packageelementId- the element in the media package to distribute- Returns:
- list of distributed media package elements
- Throws:
DistributionException- if there was a problem distributing the mediaMediaPackageException- if there was a problem with the mediapackage element
-
distributeSync
public List<MediaPackageElement> distributeSync(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability, boolean preserveReference) throws DistributionException, MediaPackageException -
distributeSync
public List<MediaPackageElement> distributeSync(String channelId, MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws DistributionException Description copied from interface:DownloadDistributionServiceDistributes the given elements synchronously. This should be used rarely since load balancing will be unavailable. However, since the dispatching logic is bypassed, synchronous execution is much faster. It is useful in interactive scenarios where you synchronously wait for job execution anyway and you don't want to make the user waiting for too long.- Specified by:
distributeSyncin interfaceDownloadDistributionService- Parameters:
channelId- The channel to retract from.mediapackage- A media package holding the elements to retract.elementIds- The IDs of the elements to retract.checkAvailability- Whether to check if the distributed elements are available through their URI.- Returns:
- The distributed elements.
- Throws:
DistributionException- In case distribution fails.
-
retractSync
public List<MediaPackageElement> retractSync(String channelId, MediaPackage mediapackage, String elementId) throws DistributionException, MediaPackageException Description copied from interface:DistributionServiceRetract a media package element from the distribution channel synchronously, bypassing the Opencast job system.- Specified by:
retractSyncin interfaceDistributionService- Parameters:
mediapackage- the media packageelementId- the media package element to retract- Returns:
- list of retracted media package elements
- Throws:
DistributionException- if there was a problem retracting the mediapackageMediaPackageException
-
retractSync
public List<MediaPackageElement> retractSync(String channelId, MediaPackage mediapackage, Set<String> elementIds) throws DistributionException Description copied from interface:DownloadDistributionServiceRetracts the given elements synchronously. This should be used rarely since load balancing will be unavailable. However, since the dispatching logic is bypassed, synchronous execution is much faster. It is useful in interactive scenarios where you synchronously wait for job execution anyway and you don't want to make the user waiting for too long.- Specified by:
retractSyncin interfaceDownloadDistributionService- Parameters:
channelId- The channel to retract from.mediapackage- A media package holding the elements to retract.elementIds- The IDs of the elements to retract.- Returns:
- The retracted elements.
- Throws:
DistributionException- In case retraction fails.
-
retractElements
protected MediaPackageElement[] retractElements(String channelId, MediaPackage mediapackage, Set<String> elementIds) throws DistributionException Retract a media package element from the distribution channel. The retracted element must not necessarily be the one given as parameterelementId. Instead, the element's distribution URI will be calculated. This way you are able to retract elements by providing the "original" element here.- Parameters:
channelId- the channel idmediapackage- the mediapackageelementIds- the element identifiers- Returns:
- the retracted element or
nullif the element was not retracted - Throws:
DistributionException- in case of an error
-
retractElement
protected MediaPackageElement retractElement(String channelId, MediaPackage mediapackage, MediaPackageElement element) throws DistributionException Retract a media package element from the distribution channel. The retracted element must not necessarily be the one given as parameterelementId. Instead, the element's distribution URI will be calculated. This way you are able to retract elements by providing the "original" element here.- Parameters:
channelId- the channel idmediapackage- the mediapackageelement- the element- Returns:
- the retracted element or
nullif the element was not retracted - Throws:
DistributionException- in case of an error
-
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:
Exception- See Also:
-
getDistributionFile
Gets the destination file to copy the contents of a mediapackage element.- Returns:
- The file to copy the content to
-
getMediaPackageDirectory
Gets the directory containing the distributed files for this mediapackage.- Returns:
- the filesystem directory
-
getDistributionUri
protected URI getDistributionUri(String channelId, String mediaPackageId, MediaPackageElement element) throws URISyntaxException Gets the URI for the element to be distributed.- Parameters:
mediaPackageId- the mediapackage identifierelement- The mediapackage element being distributed- Returns:
- The resulting URI after distribution
- Throws:
URISyntaxException- if the concrete implementation tries to create a malformed uri
-
updated
- Specified by:
updatedin interfaceorg.osgi.service.cm.ManagedService- Throws:
org.osgi.service.cm.ConfigurationException
-
setWorkspace
Description copied from class:AbstractDistributionServiceCallback for the OSGi environment to set the workspace reference.- Overrides:
setWorkspacein classAbstractDistributionService- Parameters:
workspace- the workspace
-
setServiceRegistry
Description copied from class:AbstractDistributionServiceCallback for the OSGi environment to set the service registry reference.- Overrides:
setServiceRegistryin classAbstractDistributionService- Parameters:
serviceRegistry- the service registry
-
setSecurityService
Description copied from class:AbstractDistributionServiceCallback for setting the security service.- Overrides:
setSecurityServicein classAbstractDistributionService- Parameters:
securityService- the securityService to set
-
setUserDirectoryService
Description copied from class:AbstractDistributionServiceCallback for setting the user directory service.- Overrides:
setUserDirectoryServicein classAbstractDistributionService- Parameters:
userDirectoryService- the userDirectoryService to set
-
setOrganizationDirectoryService
public void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService) Description copied from class:AbstractDistributionServiceSets a reference to the organization directory service.- Overrides:
setOrganizationDirectoryServicein classAbstractDistributionService- Parameters:
organizationDirectoryService- the organization directory
-
setTrustedHttpClient
Description copied from class:AbstractDistributionServiceCallback for the OSGi environment to set the trusted http clientreference.- Overrides:
setTrustedHttpClientin classAbstractDistributionService- Parameters:
trustedHttpClient- the trusted http client
-