Class S3Backend
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend
-
- org.apache.jackrabbit.oak.blob.cloud.s3.S3Backend
-
- All Implemented Interfaces:
SharedBackend
public class S3Backend extends AbstractSharedBackend
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 voidaddMetadataRecord(File input, String name)Adds a metadata record with the specified namevoidaddMetadataRecord(InputStream input, String name)Adds a metadata record with the specified namevoidclose()Close backend and release resources like database connection if any.voiddeleteAllMetadataRecords(String prefix)Deletes all the metadata records with the specified prefix.booleandeleteMetadataRecord(String name)Deletes the metadata record with the specified namevoiddeleteRecord(DataIdentifier identifier)Delete record identified by identifier.booleanexists(DataIdentifier identifier)Check if record identified by identifier exists in Amazon S3.Iterator<DataIdentifier>getAllIdentifiers()Returns identifiers of all records that exists in backend.List<DataRecord>getAllMetadataRecords(String prefix)Gets all the metadata with a specified prefix.Iterator<DataRecord>getAllRecords()Returns a list of all DataRecordsStringgetBucket()DataRecordgetMetadataRecord(String name)Gets the metadata of the specified name.byte[]getOrCreateReferenceKey()Returns the reference key of this backend.DataRecordgetRecord(DataIdentifier identifier)Gets the record with the specified identifiervoidinit()InitializebooleanmetadataRecordExists(String name)Checks if the metadata record with the specified name exists.InputStreamread(DataIdentifier identifier)Return inputstream of record identified by identifier.voidsetBucket(String bucket)voidsetProperties(Properties properties)Properties used to configure the backend.voidwrite(DataIdentifier identifier, File file)It uploads file to Amazon S3.-
Methods inherited from class org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend
getReferenceFromIdentifier
-
-
-
-
Method Detail
-
init
public void init() throws DataStoreExceptionDescription copied from interface:SharedBackendInitialize- 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.
-
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
-
read
public InputStream read(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedBackendReturn 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()
Description copied from interface:SharedBackendReturns identifiers of all records that exists in backend.- Returns:
- iterator consisting of all identifiers
-
deleteRecord
public void deleteRecord(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedBackendDelete record identified by identifier. No-op if identifier not found.- Throws:
DataStoreException
-
close
public void close()
Description copied from interface:SharedBackendClose backend and release resources like database connection if any.
-
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
-
addMetadataRecord
public void addMetadataRecord(InputStream input, String name) throws DataStoreException
Description copied from interface:SharedBackendAdds a metadata record with the specified name- Parameters:
input- the record input streamname- the name- Throws:
DataStoreException
-
addMetadataRecord
public void addMetadataRecord(File input, String name) throws DataStoreException
Description copied from interface:SharedBackendAdds a metadata record with the specified name- Parameters:
input- the record filename- the name- Throws:
DataStoreException
-
getMetadataRecord
public DataRecord getMetadataRecord(String name)
Description copied from interface:SharedBackendGets the metadata of the specified name.- Parameters:
name- the name of the record- Returns:
- the metadata DataRecord
-
getAllMetadataRecords
public List<DataRecord> getAllMetadataRecords(String prefix)
Description copied from interface:SharedBackendGets all the metadata with a specified prefix.- Parameters:
prefix- the prefix of the records to retrieve- Returns:
- list of all the metadata DataRecords
-
deleteMetadataRecord
public boolean deleteMetadataRecord(String name)
Description copied from interface:SharedBackendDeletes the metadata record with the specified name- Parameters:
name- the name of the record- Returns:
- boolean to indicate success of deletion
-
deleteAllMetadataRecords
public void deleteAllMetadataRecords(String prefix)
Description copied from interface:SharedBackendDeletes all the metadata records with the specified prefix.- Parameters:
prefix- the prefix of the record
-
getAllRecords
public Iterator<DataRecord> getAllRecords()
Description copied from interface:SharedBackendReturns a list of all DataRecords- Returns:
- iterator over DataRecords
-
getRecord
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedBackendGets the record with the specified identifier- Parameters:
identifier- the record identifier- Returns:
- the metadata DataRecord
- Throws:
DataStoreException
-
getOrCreateReferenceKey
public byte[] getOrCreateReferenceKey() throws DataStoreExceptionDescription copied from class:AbstractSharedBackendReturns the reference key of this backend. If one does not already exist, it is automatically created in an implementation-specific way. The default implementation simply creates a temporary random key that's valid only until the data store gets restarted. Subclasses can override and/or decorate this method to support a more persistent reference key.This method is called only once during the lifetime of a backend instance and the return value is cached in memory, so it's no problem if the implementation is slow.
- Overrides:
getOrCreateReferenceKeyin classAbstractSharedBackend- Returns:
- reference key
- Throws:
DataStoreException- if the key is not available
-
metadataRecordExists
public boolean metadataRecordExists(String name)
Description copied from interface:SharedBackendChecks if the metadata record with the specified name exists.- Parameters:
name- the name of the record- Returns:
- whether record exists
-
-