Package org.jets3t.service.multi
Class SimpleThreadedStorageService
- java.lang.Object
-
- org.jets3t.service.multi.SimpleThreadedStorageService
-
public class SimpleThreadedStorageService extends Object
S3 service wrapper that performs multiple S3 requests at a time using multi-threading and an underlying thread-safeStorageService
implementation.This class provides a simplified interface to the
ThreadedStorageService
service. It will block while doing its work, return the results of an operation when it is finished, and throw an exception if anything goes wrong.For a non-blocking multi-threading service that is more powerful, but also more complicated, see
ThreadedStorageService
.- Author:
- James Murty
-
-
Constructor Summary
Constructors Constructor Description SimpleThreadedStorageService(StorageService service)
Construct a multi-threaded service based on a StorageService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map[]
copyObjects(String sourceBucketName, String destinationBucketName, String[] sourceObjectKeys, StorageObject[] destinationObjects, boolean replaceMetadata)
Copies multiple objects within or between buckets.StorageBucket[]
createBuckets(String[] bucketNames)
Creates multiple buckets.void
deleteObjects(String bucketName, StorageObject[] objects)
Deletes multiple objectsvoid
downloadObjects(String bucketName, DownloadPackage[] downloadPackages)
A convenience method to download multiple objects from S3 to pre-existing output streams, which is particularly useful for downloading objects to files.StorageObject[]
getObjectACLs(String bucketName, StorageObject[] objects)
Retrieves Access Control List (ACL) settings for multiple objects.StorageObject[]
getObjects(String bucketName, String[] objectKeys)
Retrieves multiple objects (including details and data).StorageObject[]
getObjects(String bucketName, StorageObject[] objects)
Retrieves multiple objects (including details and data).StorageObject[]
getObjectsHeads(String bucketName, String[] objectKeys)
Retrieves details of multiple objects (details only, no data)StorageObject[]
getObjectsHeads(String bucketName, StorageObject[] objects)
Retrieves details of multiple objects (details only, no data)StorageObject[]
putACLs(String bucketName, StorageObject[] objects)
Updates/sets Access Control List (ACL) settings for multiple objects.StorageObject[]
putObjects(String bucketName, StorageObject[] objects)
Creates/uploads multiple objects.
-
-
-
Constructor Detail
-
SimpleThreadedStorageService
public SimpleThreadedStorageService(StorageService service)
Construct a multi-threaded service based on a StorageService.- Parameters:
service
- a StorageService implementation that will be used to perform S3 requests.
-
-
Method Detail
-
createBuckets
public StorageBucket[] createBuckets(String[] bucketNames) throws ServiceException
Creates multiple buckets.- Parameters:
bucketNames
- name of the buckets to create.- Returns:
- the created buckets.
- Throws:
ServiceException
-
putObjects
public StorageObject[] putObjects(String bucketName, StorageObject[] objects) throws ServiceException
Creates/uploads multiple objects.- Parameters:
bucketName
- the bucket where objects will be stored.objects
- the objects to create/upload.- Returns:
- the created/uploaded objects.
- Throws:
ServiceException
-
copyObjects
public Map[] copyObjects(String sourceBucketName, String destinationBucketName, String[] sourceObjectKeys, StorageObject[] destinationObjects, boolean replaceMetadata) throws ServiceException
Copies multiple objects within or between buckets.- Parameters:
sourceBucketName
- the name of the bucket containing the objects that will be copied.destinationBucketName
- the name of the bucket to which the objects will be copied. The destination bucket may be the same as the source bucket.sourceObjectKeys
- the key names of the objects that will be copied.destinationObjects
- objects that will be created by the copy operation. The AccessControlList setting of each object will determine the access permissions of the resultant object, and if the replaceMetadata flag is true the metadata items in each object will also be applied to the resultant object.replaceMetadata
- if true, the metadata items in the destination objects will be stored in S3 by using the REPLACE metadata copying option. If false, the metadata items will be copied unchanged from the original objects using the COPY metadata copying option.s- Throws:
ServiceException
-
deleteObjects
public void deleteObjects(String bucketName, StorageObject[] objects) throws ServiceException
Deletes multiple objects- Parameters:
bucketName
- name of the bucket containing the objects to delete.objects
- the objects to delete.- Throws:
ServiceException
-
getObjects
public StorageObject[] getObjects(String bucketName, StorageObject[] objects) throws ServiceException
Retrieves multiple objects (including details and data). The objects' data will be stored in temporary files, and can be retrieved usingStorageObject.getDataInputStream()
.- Parameters:
bucketName
- name of the bucket containing the objects.objects
- the objects to retrieve.- Returns:
- the retrieved objects.
- Throws:
ServiceException
-
getObjects
public StorageObject[] getObjects(String bucketName, String[] objectKeys) throws ServiceException
Retrieves multiple objects (including details and data). The objects' data will be stored in temporary files, and can be retrieved usingStorageObject.getDataInputStream()
.- Parameters:
bucketName
- name of the bucket containing the objects.objectKeys
- the key names of the objects to retrieve.- Returns:
- the retrieved objects.
- Throws:
ServiceException
-
getObjectsHeads
public StorageObject[] getObjectsHeads(String bucketName, StorageObject[] objects) throws ServiceException
Retrieves details of multiple objects (details only, no data)- Parameters:
bucketName
- name of the bucket containing the objects.objects
- the objects to retrieve.- Returns:
- objects populated with the details retrieved.
- Throws:
ServiceException
-
getObjectsHeads
public StorageObject[] getObjectsHeads(String bucketName, String[] objectKeys) throws ServiceException
Retrieves details of multiple objects (details only, no data)- Parameters:
bucketName
- name of the bucket containing the objects.objectKeys
- the key names of the objects to retrieve.- Returns:
- objects populated with the details retrieved.
- Throws:
ServiceException
-
getObjectACLs
public StorageObject[] getObjectACLs(String bucketName, StorageObject[] objects) throws ServiceException
Retrieves Access Control List (ACL) settings for multiple objects.- Parameters:
bucketName
- name of the bucket containing the objects.objects
- the objects whose ACLs will be retrieved.- Returns:
- objects including the ACL information retrieved.
- Throws:
ServiceException
-
putACLs
public StorageObject[] putACLs(String bucketName, StorageObject[] objects) throws ServiceException
Updates/sets Access Control List (ACL) settings for multiple objects.- Parameters:
bucketName
- name of the bucket containing the objects.objects
- objects containing ACL settings that will be updated/set.- Returns:
- objects whose ACL settings were updated/set.
- Throws:
ServiceException
-
downloadObjects
public void downloadObjects(String bucketName, DownloadPackage[] downloadPackages) throws ServiceException
A convenience method to download multiple objects from S3 to pre-existing output streams, which is particularly useful for downloading objects to files.- Parameters:
bucketName
- name of the bucket containing the objectsdownloadPackages
- an array of download package objects that manage the output of data for an object.- Throws:
ServiceException
-
-