Package org.apache.jackrabbit.aws.ext.ds
Class S3Backend
- java.lang.Object
-
- org.apache.jackrabbit.core.data.AbstractBackend
-
- org.apache.jackrabbit.aws.ext.ds.S3Backend
-
- All Implemented Interfaces:
Backend
public class S3Backend extends AbstractBackend
A data store backend that stores data on Amazon S3.
-
-
Constructor Summary
Constructors Constructor Description S3Backend()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close backend and release resources like database connection if any.Set<DataIdentifier>
deleteAllOlderThan(long min)
Delete all records which are older than timestamp.void
deleteRecord(DataIdentifier identifier)
Delete record identified by identifier.boolean
exists(DataIdentifier identifier)
Check if record identified by identifier exists in Amazon S3.boolean
exists(DataIdentifier identifier, boolean touch)
This method check the existence of record in backend.Iterator<DataIdentifier>
getAllIdentifiers()
Returns identifiers of all records that exists in backend.String
getBucket()
long
getLastModified(DataIdentifier identifier)
Return lastModified of record identified by identifier.long
getLength(DataIdentifier identifier)
Return length of record identified by identifier.void
init(CachingDataStore store, String homeDir, String config)
Initialize S3Backend.void
init(CachingDataStore store, String homeDir, Properties prop)
InputStream
read(DataIdentifier identifier)
Return inputstream of record identified by identifier.void
setBucket(String bucket)
void
setProperties(Properties properties)
Properties used to configure the backend.void
touch(DataIdentifier identifier, long minModifiedDate)
Update the lastModified of record if it's lastModified < minModifiedDate.void
touchAsync(DataIdentifier identifier, long minModifiedDate, AsyncTouchCallback callback)
Update the lastModified of record if it's lastModified < minModifiedDate asynchronously.void
write(DataIdentifier identifier, File file)
It uploads file to Amazon S3.void
writeAsync(DataIdentifier identifier, File file, AsyncUploadCallback callback)
Write file to backend in asynchronous mode.-
Methods inherited from class org.apache.jackrabbit.core.data.AbstractBackend
createAsyncWriteExecutor, getAsyncWriteExecutor, getAsyncWritePoolSize, getConfig, getDataStore, getHomeDir, setAsyncWritePoolSize, setConfig, setDataStore, setHomeDir
-
-
-
-
Method Detail
-
init
public void init(CachingDataStore store, String homeDir, String config) throws DataStoreException
Initialize S3Backend. It creates AmazonS3Client and TransferManager from aws.properties. It creates S3 bucket if it doesn't pre-exist in S3.- Specified by:
init
in interfaceBackend
- Overrides:
init
in classAbstractBackend
- Parameters:
store
-CachingDataStore
homeDir
- path of repository home dir.config
- path of config property file.- Throws:
DataStoreException
-
init
public void init(CachingDataStore store, String homeDir, Properties prop) throws DataStoreException
- Throws:
DataStoreException
-
write
public void write(DataIdentifier identifier, File file) throws DataStoreException
It uploads file to Amazon S3. If file size is greater than 5MB, this method uses parallel concurrent connections to upload.- Parameters:
identifier
- key of the filefile
- file that would be stored in backend.- Throws:
DataStoreException
- for any error.
-
writeAsync
public void writeAsync(DataIdentifier identifier, File file, AsyncUploadCallback callback) throws DataStoreException
Description copied from interface:Backend
Write file to backend in asynchronous mode.callback
- Callback interface to called after upload succeed or failed.- Throws:
DataStoreException
-
exists
public boolean exists(DataIdentifier identifier) throws DataStoreException
Check if record identified by identifier exists in Amazon S3.- Parameters:
identifier
- identifier to be checked.- Returns:
- true if records exists else false.
- Throws:
DataStoreException
-
exists
public boolean exists(DataIdentifier identifier, boolean touch) throws DataStoreException
Description copied from interface:Backend
This method check the existence of record in backend. Return true if records exists else false. This method also touch record identified by identifier if touch is true.- Throws:
DataStoreException
-
touchAsync
public void touchAsync(DataIdentifier identifier, long minModifiedDate, AsyncTouchCallback callback) throws DataStoreException
Description copied from interface:Backend
Update the lastModified of record if it's lastModified < minModifiedDate asynchronously. Result of update is passed using appropriateAsyncTouchCallback
methods. If identifier's lastModified > minModifiedAsyncTouchCallback.onAbort(AsyncTouchResult)
is called. Any exception is communicated throughAsyncTouchCallback.onFailure(AsyncTouchResult)
. On successful update of lastModified,AsyncTouchCallback.onSuccess(AsyncTouchResult)
is invoked.- Throws:
DataStoreException
-
touch
public void touch(DataIdentifier identifier, long minModifiedDate) throws DataStoreException
Description copied from interface:Backend
Update the lastModified of record if it's lastModified < minModifiedDate.- Throws:
DataStoreException
-
read
public InputStream read(DataIdentifier identifier) throws DataStoreException
Description copied from interface:Backend
Return inputstream of record identified by identifier.- Parameters:
identifier
- identifier of record.- Returns:
- inputstream of the record.
- Throws:
DataStoreException
- if record not found or any error.
-
getAllIdentifiers
public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
Description copied from interface:Backend
Returns identifiers of all records that exists in backend.- Returns:
- iterator consisting of all identifiers
- Throws:
DataStoreException
-
getLastModified
public long getLastModified(DataIdentifier identifier) throws DataStoreException
Description copied from interface:Backend
Return lastModified of record identified by identifier.- Parameters:
identifier
- identifier of record.- Returns:
- lastModified of the record.
- Throws:
DataStoreException
- if record not found or any error.
-
getLength
public long getLength(DataIdentifier identifier) throws DataStoreException
Description copied from interface:Backend
Return length of record identified by identifier.- Parameters:
identifier
- identifier of record.- Returns:
- length of the record.
- Throws:
DataStoreException
- if record not found or any error.
-
deleteRecord
public void deleteRecord(DataIdentifier identifier) throws DataStoreException
Description copied from interface:Backend
Delete record identified by identifier. No-op if identifier not found.- Throws:
DataStoreException
-
deleteAllOlderThan
public Set<DataIdentifier> deleteAllOlderThan(long min) throws DataStoreException
Description copied from interface:Backend
Delete all records which are older than timestamp.- Returns:
Set
of identifiers which are deleted.- Throws:
DataStoreException
-
close
public void close() throws DataStoreException
Description copied from class:AbstractBackend
Close backend and release resources like database connection if any.- Specified by:
close
in interfaceBackend
- Overrides:
close
in classAbstractBackend
- Throws:
DataStoreException
-
getBucket
public String getBucket()
-
setBucket
public void setBucket(String bucket)
-
setProperties
public void setProperties(Properties properties)
Properties used to configure the backend. If provided explicitly before init is invoked then these take precedence- Parameters:
properties
- to configure S3Backend
-
-