public class S3BinaryManager extends CachingBinaryManager implements BlobProvider
The BLOBs are cached locally on first access for efficiency.
Because the BLOB length can be accessed independently of the binary stream, it is also cached in a simple text file if accessed before the stream.
Modifier and Type | Class and Description |
---|---|
static class |
S3BinaryManager.S3BinaryGarbageCollector
Garbage collector for S3 binaries that stores the marked (in use) binaries in memory.
|
class |
S3BinaryManager.S3FileStorage |
Modifier and Type | Field and Description |
---|---|
protected com.amazonaws.services.s3.AmazonS3 |
amazonS3 |
static String |
AWS_ID_ENV_KEY |
static String |
AWS_ID_KEY |
static String |
AWS_SECRET_ENV_KEY |
static String |
AWS_SECRET_KEY |
protected com.amazonaws.auth.AWSCredentialsProvider |
awsCredentialsProvider |
static String |
BUCKET_NAME_KEY |
static String |
BUCKET_PREFIX_KEY |
static String |
BUCKET_REGION_KEY |
protected String |
bucketName |
protected String |
bucketNamePrefix |
static String |
CACHE_SIZE_KEY |
protected com.amazonaws.ClientConfiguration |
clientConfiguration |
static String |
CONNECTION_MAX_KEY
AWS ClientConfiguration default 50
|
static String |
CONNECTION_RETRY_KEY
AWS ClientConfiguration default 3 (with exponential backoff)
|
static String |
CONNECTION_TIMEOUT_KEY
AWS ClientConfiguration default 50*1000 = 50s
|
protected com.amazonaws.services.s3.model.CryptoConfiguration |
cryptoConfiguration |
static String |
DEFAULT_BUCKET_REGION |
static String |
DEFAULT_CACHE_SIZE |
static String |
DEFAULT_DIRECTDOWNLOAD |
static int |
DEFAULT_DIRECTDOWNLOAD_EXPIRE |
protected boolean |
directDownload |
static String |
DIRECTDOWNLOAD_EXPIRE_KEY |
static String |
DIRECTDOWNLOAD_KEY |
protected int |
directDownloadExpire |
protected com.amazonaws.services.s3.model.EncryptionMaterials |
encryptionMaterials |
static String |
ENDPOINT_KEY |
protected boolean |
isEncrypted |
static String |
KEYSTORE_FILE_KEY |
static String |
KEYSTORE_PASS_KEY |
static String |
PRIVKEY_ALIAS_KEY |
static String |
PRIVKEY_PASS_KEY |
static String |
SOCKET_TIMEOUT_KEY
AWS ClientConfiguration default 50*1000 = 50s
|
protected com.amazonaws.services.s3.transfer.TransferManager |
transferManager |
cachedir, fileCache, fileStorage, LEN_DIGEST_SUFFIX
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTH
PROP_KEY, PROP_PATH
Constructor and Description |
---|
S3BinaryManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
abortOldUploads()
Aborts uploads that crashed and are older than 1 day.
|
void |
close()
Closes the binary manager and releases all resources and temporary objects held by it.
|
protected void |
createGarbageCollector() |
protected String |
getContentDispositionHeader(Blob blob,
javax.servlet.http.HttpServletRequest servletRequest) |
protected String |
getContentTypeHeader(Blob blob) |
protected String |
getDefaultDigestAlgorithm()
Gets the default message digest to use to hash binaries.
|
protected static int |
getIntProperty(String key)
Gets an integer framework property, or -1 if undefined.
|
protected URI |
getS3URI(String digest,
Blob blob,
javax.servlet.http.HttpServletRequest servletRequest) |
URI |
getURI(ManagedBlob blob,
BlobManager.UsageHint hint,
javax.servlet.http.HttpServletRequest servletRequest)
Gets an
URI for the content of a managed blob. |
void |
initialize(String blobProviderId,
Map<String,String> properties)
Initializes the binary manager.
|
static boolean |
isMD5(String digest) |
protected static boolean |
isMissingKey(com.amazonaws.AmazonClientException e) |
protected FileStorage |
newFileStorage() |
Blob |
readBlob(BlobManager.BlobInfo blobInfo)
Reads a
Blob from storage. |
protected void |
removeBinary(String digest) |
boolean |
supportsWrite()
Checks if write is supported
|
String |
writeBlob(Blob blob,
Document doc)
Writes a
Blob to storage and returns information about it. |
getBinary, getBinary, getFile, getLength, getLengthFromCache, initializeCache, initializeCache, putLengthInCache
getBinary, getDescriptor, getDigestAlgorithm, getGarbageCollector, storeAndDigest, toHexString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
freezeVersion, getAppLinks, getAvailableConversions, getBinaryManager, getConvertedStream, getStream, getThumbnail, isVersion
public static final String BUCKET_NAME_KEY
public static final String BUCKET_PREFIX_KEY
public static final String BUCKET_REGION_KEY
public static final String DEFAULT_BUCKET_REGION
public static final String AWS_ID_KEY
public static final String AWS_ID_ENV_KEY
public static final String AWS_SECRET_KEY
public static final String AWS_SECRET_ENV_KEY
public static final String CACHE_SIZE_KEY
public static final String DEFAULT_CACHE_SIZE
public static final String CONNECTION_MAX_KEY
public static final String CONNECTION_RETRY_KEY
public static final String CONNECTION_TIMEOUT_KEY
public static final String SOCKET_TIMEOUT_KEY
public static final String KEYSTORE_FILE_KEY
public static final String KEYSTORE_PASS_KEY
public static final String PRIVKEY_ALIAS_KEY
public static final String PRIVKEY_PASS_KEY
public static final String ENDPOINT_KEY
public static final String DIRECTDOWNLOAD_KEY
public static final String DEFAULT_DIRECTDOWNLOAD
public static final String DIRECTDOWNLOAD_EXPIRE_KEY
public static final int DEFAULT_DIRECTDOWNLOAD_EXPIRE
protected String bucketName
protected String bucketNamePrefix
protected com.amazonaws.auth.AWSCredentialsProvider awsCredentialsProvider
protected com.amazonaws.ClientConfiguration clientConfiguration
protected com.amazonaws.services.s3.model.EncryptionMaterials encryptionMaterials
protected boolean isEncrypted
protected com.amazonaws.services.s3.model.CryptoConfiguration cryptoConfiguration
protected com.amazonaws.services.s3.AmazonS3 amazonS3
protected com.amazonaws.services.s3.transfer.TransferManager transferManager
protected boolean directDownload
protected int directDownloadExpire
public S3BinaryManager()
protected String getDefaultDigestAlgorithm()
AbstractBinaryManager
getDefaultDigestAlgorithm
in class AbstractBinaryManager
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
BinaryManager
initialize
in interface BinaryManager
initialize
in interface BlobProvider
initialize
in class CachingBinaryManager
blobProviderId
- the blob provider id for this binary managerproperties
- initialization propertiesIOException
public void close()
BinaryManager
close
in interface BinaryManager
close
in interface BlobProvider
close
in class CachingBinaryManager
protected void abortOldUploads() throws IOException
IOException
protected static int getIntProperty(String key)
protected void createGarbageCollector()
protected void removeBinary(String digest)
protected static boolean isMissingKey(com.amazonaws.AmazonClientException e)
protected FileStorage newFileStorage()
public Blob readBlob(BlobManager.BlobInfo blobInfo) throws IOException
BlobProvider
Blob
from storage.readBlob
in interface BlobProvider
blobInfo
- the blob informationIOException
public String writeBlob(Blob blob, Document doc) throws IOException
BlobProvider
Blob
to storage and returns information about it.
Called to store a user-created blob.
writeBlob
in interface BlobProvider
blob
- the blobdoc
- the document to which this blob belongsIOException
public boolean supportsWrite()
BlobProvider
supportsWrite
in interface BlobProvider
true
if write is supportedpublic URI getURI(ManagedBlob blob, BlobManager.UsageHint hint, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
BlobProvider
URI
for the content of a managed blob.getURI
in interface BlobProvider
blob
- the managed blobhint
- BlobManager.UsageHint
servletRequest
- the servlet request, or null
URI
, or null
if none availableIOException
protected URI getS3URI(String digest, Blob blob, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
IOException
protected String getContentTypeHeader(Blob blob)
protected String getContentDispositionHeader(Blob blob, javax.servlet.http.HttpServletRequest servletRequest)
Copyright © 2015 Nuxeo SA. All rights reserved.