Package org.nuxeo.ecm.core.storage.gcp
Class GoogleStorageBinaryManager
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
-
- org.nuxeo.ecm.core.blob.binary.CachingBinaryManager
-
- org.nuxeo.ecm.blob.AbstractCloudBinaryManager
-
- org.nuxeo.ecm.core.storage.gcp.GoogleStorageBinaryManager
-
- All Implemented Interfaces:
BinaryManager
,BlobProvider
public class GoogleStorageBinaryManager extends AbstractCloudBinaryManager
A Binary Manager that stores binaries as Google Storage BLOBsThe 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. Related to GCP credentials, here are the options:
- nuxeo.gcp.credentials=/path/to/file.json
- nuxeo.gcp.credentials=file.json (located in nxserver/config)
- If nothing is set, Nuxeo will look into 'gcp-credentials.json' file by default (located in nxserver/config)
- Since:
- 10.10-HF12
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
GoogleStorageBinaryManager.GCPFileStorage
static class
GoogleStorageBinaryManager.GoogleStorageBinaryGarbageCollector
Garbage collector for GCP binaries that stores the marked (in use) binaries in memory.
-
Field Summary
Fields Modifier and Type Field Description protected com.google.cloud.storage.Bucket
bucket
static String
BUCKET_NAME_PROPERTY
static String
BUCKET_PREFIX_PROPERTY
protected String
bucketName
protected String
bucketPrefix
protected int
chunkSize
static int
DEFAULT_UPLOAD_CHUNK_SIZE
Default is taken fromBaseWriteChannel
.static String
DELIMITER
static String
GCP_JSON_FILE
static String
GOOGLE_APPLICATION_CREDENTIALS
static String
GOOGLE_PLATFORM_SCOPE
static String
GOOGLE_STORAGE_SCOPE
static String
PROJECT_ID_PROPERTY
protected com.google.cloud.storage.Storage
storage
static String
SYSTEM_PROPERTY_PREFIX
static String
UPLOAD_CHUNK_SIZE_PROPERTY
-
Fields inherited from class org.nuxeo.ecm.blob.AbstractCloudBinaryManager
CACHE_COUNT_PROPERTY, CACHE_MIN_AGE_PROPERTY, CACHE_SIZE_PROPERTY, DEFAULT_CACHE_COUNT, DEFAULT_CACHE_MIN_AGE, DEFAULT_CACHE_SIZE, DEFAULT_DIRECTDOWNLOAD, DEFAULT_DIRECTDOWNLOAD_EXPIRE, DIGEST_ALGORITHM_PROPERTY, directDownload, DIRECTDOWNLOAD_EXPIRE_PROPERTY, DIRECTDOWNLOAD_PROPERTY, directDownloadExpire, namespace, transientFlag
-
Fields inherited from class org.nuxeo.ecm.core.blob.binary.CachingBinaryManager
cachedir, fileCache, fileStorage
-
Fields inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, digestPattern, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, properties, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTH
-
Fields inherited from interface org.nuxeo.ecm.core.blob.binary.BinaryManager
PROP_KEY, PROP_PATH
-
-
Constructor Summary
Constructors Constructor Description GoogleStorageBinaryManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
deleteBucket(String bucketName)
Deletes a bucket (and all its blobs) with the givenbucketName
.com.google.cloud.storage.Bucket
getBucket()
protected FileStorage
getFileStorage()
com.google.cloud.storage.Bucket
getOrCreateBucket(String bucketName)
Gets or creates a bucket with the givenbucketName
.protected String
getSystemPropertyPrefix()
Gets the prefix used for configuration using system properties.protected BinaryGarbageCollector
instantiateGarbageCollector()
protected static boolean
isMD5(String digest)
void
removeBinaries(Collection<String> digests)
Remove definitively a set of binariesprotected void
removeBinary(String digest)
protected void
setupCloudClient()
Configure Cloud client using properties-
Methods inherited from class org.nuxeo.ecm.blob.AbstractCloudBinaryManager
getBinaryManager, getBooleanProperty, getContentDispositionHeader, getContentTypeHeader, getDefaultDigestAlgorithm, getIntProperty, getIntProperty, getProperties, getProperty, getProperty, getRemoteUri, getSystemPropertyName, getURI, initialize, isDirectDownload, isTransient, performsExternalAccessControl, readBlob, supportsUserUpdate, supportsUserUpdateDefaultTrue, writeBlob
-
Methods inherited from class org.nuxeo.ecm.core.blob.binary.CachingBinaryManager
close, getBinary, getBinary, getFile, initializeCache, initializeCache, initializeCache
-
Methods inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
computeDigestPattern, getBinary, getDescriptor, getDigestAlgorithm, getGarbageCollector, isValidDigest, setDescriptor, storeAndDigest, toHexString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.blob.BlobProvider
allowByteRange, canConvert, close, deleteBlob, getAppLinks, getAvailableConversions, getBinaryGarbageCollector, getFile, getStatus, getStream, getStream, getThumbnail, hasCreateFromKeyPermission, isRecordMode, isTransactional, isVersion, readBlob, supportsSync, updateBlob, writeBlob
-
-
-
-
Field Detail
-
BUCKET_NAME_PROPERTY
public static final String BUCKET_NAME_PROPERTY
- See Also:
- Constant Field Values
-
BUCKET_PREFIX_PROPERTY
public static final String BUCKET_PREFIX_PROPERTY
- See Also:
- Constant Field Values
-
UPLOAD_CHUNK_SIZE_PROPERTY
public static final String UPLOAD_CHUNK_SIZE_PROPERTY
- Since:
- 11.4
- See Also:
- Constant Field Values
-
DEFAULT_UPLOAD_CHUNK_SIZE
public static final int DEFAULT_UPLOAD_CHUNK_SIZE
Default is taken fromBaseWriteChannel
.- Since:
- 11.4
- See Also:
- Constant Field Values
-
PROJECT_ID_PROPERTY
public static final String PROJECT_ID_PROPERTY
- See Also:
- Constant Field Values
-
GOOGLE_APPLICATION_CREDENTIALS
public static final String GOOGLE_APPLICATION_CREDENTIALS
- See Also:
- Constant Field Values
-
GOOGLE_PLATFORM_SCOPE
public static final String GOOGLE_PLATFORM_SCOPE
- See Also:
- Constant Field Values
-
GOOGLE_STORAGE_SCOPE
public static final String GOOGLE_STORAGE_SCOPE
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_PREFIX
public static final String SYSTEM_PROPERTY_PREFIX
- See Also:
- Constant Field Values
-
DELIMITER
public static final String DELIMITER
- See Also:
- Constant Field Values
-
GCP_JSON_FILE
public static final String GCP_JSON_FILE
- See Also:
- Constant Field Values
-
bucketName
protected String bucketName
-
bucketPrefix
protected String bucketPrefix
-
bucket
protected com.google.cloud.storage.Bucket bucket
-
storage
protected com.google.cloud.storage.Storage storage
-
chunkSize
protected int chunkSize
- Since:
- 11.4
-
-
Constructor Detail
-
GoogleStorageBinaryManager
public GoogleStorageBinaryManager()
-
-
Method Detail
-
setupCloudClient
protected void setupCloudClient()
Description copied from class:AbstractCloudBinaryManager
Configure Cloud client using properties- Specified by:
setupCloudClient
in classAbstractCloudBinaryManager
-
getOrCreateBucket
public com.google.cloud.storage.Bucket getOrCreateBucket(String bucketName)
Gets or creates a bucket with the givenbucketName
.- Returns:
- the bucket instance.
-
deleteBucket
public boolean deleteBucket(String bucketName)
Deletes a bucket (and all its blobs) with the givenbucketName
.- Returns:
- boolean if bucket has been deleted or not.
-
getBucket
public com.google.cloud.storage.Bucket getBucket()
-
getFileStorage
protected FileStorage getFileStorage()
- Specified by:
getFileStorage
in classAbstractCloudBinaryManager
-
getSystemPropertyPrefix
protected String getSystemPropertyPrefix()
Description copied from class:AbstractCloudBinaryManager
Gets the prefix used for configuration using system properties.- Specified by:
getSystemPropertyPrefix
in classAbstractCloudBinaryManager
-
instantiateGarbageCollector
protected BinaryGarbageCollector instantiateGarbageCollector()
- Specified by:
instantiateGarbageCollector
in classAbstractCloudBinaryManager
-
removeBinaries
public void removeBinaries(Collection<String> digests)
Description copied from interface:BinaryManager
Remove definitively a set of binaries- Specified by:
removeBinaries
in interfaceBinaryManager
- Specified by:
removeBinaries
in classAbstractCloudBinaryManager
- Parameters:
digests
- a set of digests, must not benull
.
-
removeBinary
protected void removeBinary(String digest)
-
-