Class AwsS3DistributionServiceImpl
java.lang.Object
org.opencastproject.job.api.AbstractJobProducer
org.opencastproject.distribution.api.AbstractDistributionService
org.opencastproject.distribution.aws.s3.AwsS3DistributionServiceImpl
- All Implemented Interfaces:
org.opencastproject.distribution.api.DistributionService,org.opencastproject.distribution.api.DownloadDistributionService,org.opencastproject.distribution.aws.s3.api.AwsS3DistributionService,org.opencastproject.job.api.JobProducer
public class AwsS3DistributionServiceImpl
extends org.opencastproject.distribution.api.AbstractDistributionService
implements org.opencastproject.distribution.aws.s3.api.AwsS3DistributionService, org.opencastproject.distribution.api.DistributionService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumList of available operations on jobs -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final floatThe load on the system introduced by creating a distribute jobstatic final intstatic final intstatic final intDefault expiration time for presigned URL in millis, 6 hoursstatic final floatThe load on the system introduced by creating a retract jobstatic final Stringstatic final Stringstatic final StringJob typestatic final Stringstatic final StringFields 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 AWS S3 distribution service. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) protected StringBuilds the aws s3 object name using the raw elementID and filenameprotected StringbuildObjectName(String channelId, String mpId, org.opencastproject.mediapackage.MediaPackageElement element) Builds the aws s3 object name.protected voidCreates the AWS S3 bucket if it doesn't exist yet.voidorg.opencastproject.job.api.Jobdistribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) org.opencastproject.job.api.Jobdistribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, String elementId, boolean checkAvailability) org.opencastproject.job.api.Jobdistribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, Set<String> elementIds, boolean checkAvailability) org.opencastproject.job.api.Jobdistribute(String pubChannelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, Set<String> downloadIds, boolean checkAvailability, boolean preserveReference) org.opencastproject.mediapackage.MediaPackageElementdistributeElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, org.opencastproject.mediapackage.MediaPackageElement element, boolean checkAvailability) Distribute a media package element to AWS S3.org.opencastproject.mediapackage.MediaPackageElement[]distributeElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) Distribute Mediapackage elements to the download distribution service.List<org.opencastproject.mediapackage.MediaPackageElement> distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) List<org.opencastproject.mediapackage.MediaPackageElement> distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) protected StringgetDistributedObjectName(org.opencastproject.mediapackage.MediaPackageElement element) Gets the distributed object's name.protected URIgetDistributionUri(String objectName) Gets the URI for the element to be distributed.presignedURI(URI uri) protected Stringprocess(org.opencastproject.job.api.Job job) org.opencastproject.job.api.Jobretract(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) org.opencastproject.job.api.Jobretract(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds) protected org.opencastproject.mediapackage.MediaPackageElementretractElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, org.opencastproject.mediapackage.MediaPackageElement element) Retracts the media package element with the given identifier from the distribution channel.protected org.opencastproject.mediapackage.MediaPackageElement[]retractElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds) Retract a media package element from the distribution channel.List<org.opencastproject.mediapackage.MediaPackageElement> retractSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) List<org.opencastproject.mediapackage.MediaPackageElement> retractSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, Set<String> elementIds) protected voidsetBucketName(String bucketName) protected voidsetOpencastDistributionUrl(String distributionUrl) voidsetOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryService) protected voidsetS3(com.amazonaws.services.s3.AmazonS3 s3) The methods below are used by the test classprotected voidsetS3TransferManager(com.amazonaws.services.s3.transfer.TransferManager s3TransferManager) voidsetSecurityService(org.opencastproject.security.api.SecurityService securityService) voidsetServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry) protected voidsetStorageTmp(String path) voidsetUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService) voidsetWorkspace(org.opencastproject.workspace.api.Workspace workspace) Methods inherited from class org.opencastproject.distribution.api.AbstractDistributionService
getOrganizationDirectoryService, getSecurityService, getServiceRegistry, getTrustedHttpClient, getUserDirectoryService, setTrustedHttpClientMethods inherited from class org.opencastproject.job.api.AbstractJobProducer
acceptJob, countJobs, finallyUpdateJob, getJobType, incident, isReadyToAccept, isReadyToAcceptJobs
-
Field Details
-
JOB_TYPE
Job type- See Also:
-
AWS_S3_DISTRIBUTION_ENABLE
- See Also:
-
AWS_S3_DISTRIBUTION_BASE_CONFIG
- See Also:
-
AWS_S3_ACCESS_KEY_ID_CONFIG
- See Also:
-
AWS_S3_SECRET_ACCESS_KEY_CONFIG
- See Also:
-
AWS_S3_REGION_CONFIG
- See Also:
-
AWS_S3_BUCKET_CONFIG
- See Also:
-
AWS_S3_ENDPOINT_CONFIG
- See Also:
-
AWS_S3_PATH_STYLE_CONFIG
- See Also:
-
AWS_S3_PRESIGNED_URL_CONFIG
- See Also:
-
AWS_S3_PRESIGNED_URL_VALID_DURATION_CONFIG
- See Also:
-
AWS_S3_MAX_CONNECTIONS
- See Also:
-
AWS_S3_CONNECTION_TIMEOUT
- See Also:
-
AWS_S3_MAX_RETRIES
- See Also:
-
DISTRIBUTE_JOB_LOAD_KEY
- See Also:
-
RETRACT_JOB_LOAD_KEY
- See Also:
-
OPENCAST_STORAGE_DIR
- See Also:
-
DEFAULT_TEMP_DIR
- See Also:
-
DEFAULT_MAX_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONS- See Also:
-
DEFAULT_CONNECTION_TIMEOUT
public static final int DEFAULT_CONNECTION_TIMEOUT- See Also:
-
DEFAULT_MAX_RETRIES
public static final int DEFAULT_MAX_RETRIES- 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:
-
DEFAULT_PRESIGNED_URL_EXPIRE_MILLIS
public static final int DEFAULT_PRESIGNED_URL_EXPIRE_MILLISDefault expiration time for presigned URL in millis, 6 hours- See Also:
-
-
Constructor Details
-
AwsS3DistributionServiceImpl
public AwsS3DistributionServiceImpl()Creates a new instance of the AWS S3 distribution service.
-
-
Method Details
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) - Overrides:
activatein classorg.opencastproject.job.api.AbstractJobProducer
-
getDistributionType
- Specified by:
getDistributionTypein interfaceorg.opencastproject.distribution.api.DistributionService
-
deactivate
public void deactivate() -
distribute
public org.opencastproject.job.api.Job distribute(String pubChannelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, Set<String> downloadIds, boolean checkAvailability, boolean preserveReference) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException - Specified by:
distributein interfaceorg.opencastproject.distribution.api.DownloadDistributionService- Throws:
org.opencastproject.distribution.api.DistributionExceptionorg.opencastproject.mediapackage.MediaPackageException
-
distribute
public org.opencastproject.job.api.Job distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, Set<String> elementIds, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException - Specified by:
distributein interfaceorg.opencastproject.distribution.api.DownloadDistributionService- Throws:
org.opencastproject.distribution.api.DistributionExceptionorg.opencastproject.mediapackage.MediaPackageException- See Also:
-
distribute
public org.opencastproject.job.api.Job distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException - Specified by:
distributein interfaceorg.opencastproject.distribution.api.DistributionService- Throws:
org.opencastproject.distribution.api.DistributionExceptionorg.opencastproject.mediapackage.MediaPackageException- See Also:
-
distribute
public org.opencastproject.job.api.Job distribute(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, String elementId, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException - Specified by:
distributein interfaceorg.opencastproject.distribution.api.DownloadDistributionService- Throws:
org.opencastproject.distribution.api.DistributionExceptionorg.opencastproject.mediapackage.MediaPackageException- See Also:
-
distributeElements
public org.opencastproject.mediapackage.MediaPackageElement[] distributeElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws org.opencastproject.distribution.api.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:
org.opencastproject.distribution.api.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 org.opencastproject.mediapackage.MediaPackageElement distributeElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, org.opencastproject.mediapackage.MediaPackageElement element, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException Distribute a media package element to AWS S3.- Parameters:
mediaPackage- The media package that contains the element to distribute.element- The element that should be distributed contained within the media package.checkAvailability- Checks if the distributed element is available- Returns:
- A reference to the MediaPackageElement that has been distributed.
- Throws:
org.opencastproject.distribution.api.DistributionException
-
retract
public org.opencastproject.job.api.Job retract(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) throws org.opencastproject.distribution.api.DistributionException - Specified by:
retractin interfaceorg.opencastproject.distribution.api.DistributionService- Throws:
org.opencastproject.distribution.api.DistributionException
-
retract
public org.opencastproject.job.api.Job retract(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds) throws org.opencastproject.distribution.api.DistributionException - Specified by:
retractin interfaceorg.opencastproject.distribution.api.DownloadDistributionService- Throws:
org.opencastproject.distribution.api.DistributionException
-
distributeSync
public List<org.opencastproject.mediapackage.MediaPackageElement> distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) throws org.opencastproject.distribution.api.DistributionException, org.opencastproject.mediapackage.MediaPackageException - Specified by:
distributeSyncin interfaceorg.opencastproject.distribution.api.DistributionService- Throws:
org.opencastproject.distribution.api.DistributionExceptionorg.opencastproject.mediapackage.MediaPackageException
-
distributeSync
public List<org.opencastproject.mediapackage.MediaPackageElement> distributeSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds, boolean checkAvailability) throws org.opencastproject.distribution.api.DistributionException - Specified by:
distributeSyncin interfaceorg.opencastproject.distribution.api.DownloadDistributionService- Throws:
org.opencastproject.distribution.api.DistributionException
-
retractSync
public List<org.opencastproject.mediapackage.MediaPackageElement> retractSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, String elementId) throws org.opencastproject.distribution.api.DistributionException - Specified by:
retractSyncin interfaceorg.opencastproject.distribution.api.DistributionService- Throws:
org.opencastproject.distribution.api.DistributionException
-
retractSync
public List<org.opencastproject.mediapackage.MediaPackageElement> retractSync(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, Set<String> elementIds) throws org.opencastproject.distribution.api.DistributionException - Specified by:
retractSyncin interfaceorg.opencastproject.distribution.api.DownloadDistributionService- Throws:
org.opencastproject.distribution.api.DistributionException
-
retractElement
protected org.opencastproject.mediapackage.MediaPackageElement retractElement(String channelId, org.opencastproject.mediapackage.MediaPackage mediaPackage, org.opencastproject.mediapackage.MediaPackageElement element) throws org.opencastproject.distribution.api.DistributionException Retracts the media package element with the given identifier from the distribution channel.- Parameters:
channelId- the channel idmediaPackage- the media packageelement- the element- Returns:
- the retracted element or
nullif the element was not retracted - Throws:
org.opencastproject.distribution.api.DistributionException
-
retractElements
protected org.opencastproject.mediapackage.MediaPackageElement[] retractElements(String channelId, org.opencastproject.mediapackage.MediaPackage mediapackage, Set<String> elementIds) throws org.opencastproject.distribution.api.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:
org.opencastproject.distribution.api.DistributionException- in case of an error
-
buildObjectName
protected String buildObjectName(String channelId, String mpId, org.opencastproject.mediapackage.MediaPackageElement element) Builds the aws s3 object name.- Parameters:
channelId-mpId-element-- Returns:
-
buildObjectName
protected String buildObjectName(String orgId, String channelId, String mpId, String elementId, String fileName) Builds the aws s3 object name using the raw elementID and filename- Parameters:
orgId-channelId-mpId-elementId-fileName-- Returns:
-
getDistributionUri
Gets the URI for the element to be distributed.- Returns:
- The resulting URI after distribution
- Throws:
URISyntaxException- if the concrete implementation tries to create a malformed uri
-
getDistributedObjectName
protected String getDistributedObjectName(org.opencastproject.mediapackage.MediaPackageElement element) Gets the distributed object's name.- Returns:
- The distributed object name
-
process
- Specified by:
processin classorg.opencastproject.job.api.AbstractJobProducer- Throws:
Exception- See Also:
-
createAWSBucket
protected void createAWSBucket()Creates the AWS S3 bucket if it doesn't exist yet. -
presignedURI
- Throws:
URISyntaxException
-
setS3
protected void setS3(com.amazonaws.services.s3.AmazonS3 s3) The methods below are used by the test class -
setS3TransferManager
protected void setS3TransferManager(com.amazonaws.services.s3.transfer.TransferManager s3TransferManager) -
setBucketName
-
setOpencastDistributionUrl
-
setStorageTmp
-
setWorkspace
public void setWorkspace(org.opencastproject.workspace.api.Workspace workspace) - Overrides:
setWorkspacein classorg.opencastproject.distribution.api.AbstractDistributionService
-
setServiceRegistry
public void setServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry serviceRegistry) - Overrides:
setServiceRegistryin classorg.opencastproject.distribution.api.AbstractDistributionService
-
setSecurityService
public void setSecurityService(org.opencastproject.security.api.SecurityService securityService) - Overrides:
setSecurityServicein classorg.opencastproject.distribution.api.AbstractDistributionService
-
setUserDirectoryService
public void setUserDirectoryService(org.opencastproject.security.api.UserDirectoryService userDirectoryService) - Overrides:
setUserDirectoryServicein classorg.opencastproject.distribution.api.AbstractDistributionService
-
setOrganizationDirectoryService
public void setOrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService organizationDirectoryService) - Overrides:
setOrganizationDirectoryServicein classorg.opencastproject.distribution.api.AbstractDistributionService
-