Class MongoDBTransientStore
java.lang.Object
org.nuxeo.ecm.core.mongodb.transientstore.MongoDBTransientStore
- All Implemented Interfaces:
TransientStore
,TransientStoreProvider
Transient Store optimized for MongoDB, using a blob provider for binaries. It can replace the
KeyValueBlobTransientStore implementation, it uses the same configuration.
A MongoDB collection is created per store, the name is prefixed by "transient.". If not provided the blob provider is created using a default configuration with "transient_" prefix that gives the required transient property.
The storage format is the following:
{ "_id" : $KEY, "completed" : false, "ttl" : ISODate("2022-11-17T12:10:16.568Z"), "params" : { "chunked" : "false" } }, "blobs" : [ { "key" : ..., "mimetype" : ..., "encoding" : ..., "filename" : ..., "length" : NumberLong(131984), "digest" : ... } ], "blobSize" : NumberLong(131984), "blobCount" : 1 }The total size of the storage is computed with an aggregation on the blobSize property.
- Since:
- 2021.30
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
static final String
static final String
protected String
static final String
protected com.mongodb.client.MongoCollection<org.bson.Document>
static final String
static final String
protected TransientStoreConfig
static final String
static final String
static final String
static final String
protected String
static final String
static final String
static final String
protected int
static final String
static final String
static final String
static final String
static final Double
protected int
protected long
static final String
static final String
protected static final long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.bson.Document
createEntry
(String key) protected Serializable
deSerializeValue
(Object value) void
doGC()
Runs garbage collecting to delete the file system resources that are associated with entries that were removed.boolean
Returnstrue
if an entry exists with the givenkey
.Gets the blobs associated with the entry with the givenkey
.protected com.mongodb.client.MongoCollection<org.bson.Document>
getColl()
getParameter
(String key, String parameter) Gets the value ofparameter
in the entry with the givenkey
.getParameters
(String key) Gets values of the parameters in the entry with the givenkey
.long
Returns the size of the blobs associated with the entry with the givenkey
or-1
if entry does not exist.long
Returns the size (in bytes) of the disk storage used for blobs.void
init
(TransientStoreConfig config) Initializes the store from the givenconfig
.boolean
isCompleted
(String key) Returnstrue
if the entry with the givenkey
is ready.Returns aStream
of keys for all entries.void
Associates the givenblobs
with the entry with the givenkey
.void
putParameter
(String key, String parameter, Serializable value) Setsparameter
tovalue
in the entry with the givenkey
.void
putParameters
(String key, Map<String, Serializable> parameters) Putsparameters
in the entry with the givenkey
.void
Informs the store that the entry with the givenkey
can be released if TTL or GC parameters require to do some cleanup.void
Removes entry with the givenkey
.void
Removes all entries from the store.protected Object
serializeValue
(Serializable value) void
setCompleted
(String key, boolean completed) Marks the entry with the givenkey
as ready.protected void
setTTL
(org.bson.Document entry, int ttlSeconds) void
shutdown()
Shuts down the store.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.transientstore.api.TransientStoreProvider
keySet
-
Field Details
-
COLLECTION_NAME_PROPERTY
- See Also:
-
DEFAULT_COLLECTION_NAME
- See Also:
-
TRANSIENT_DATABASE_ID
- See Also:
-
CONFIG_BLOB_PROVIDER
- See Also:
-
CONFIG_DEFAULT_BLOB_PROVIDER
- See Also:
-
CONFIG_DEFAULT_BLOB_PROVIDER_DEFAULT
- See Also:
-
KEY
- See Also:
-
MIMETYPE
- See Also:
-
ENCODING
- See Also:
-
FILENAME
- See Also:
-
LENGTH
- See Also:
-
DIGEST
- See Also:
-
ID_KEY
- See Also:
-
TTL_KEY
- See Also:
-
COMPLETED_KEY
- See Also:
-
BLOBS_KEY
- See Also:
-
BLOB_SIZE_KEY
- See Also:
-
BLOB_COUNT_KEY
- See Also:
-
ONE
-
WARN_DURATION_MS_THRESHOLD
protected static final long WARN_DURATION_MS_THRESHOLD- See Also:
-
coll
protected com.mongodb.client.MongoCollection<org.bson.Document> coll -
config
-
firstLevelTTL
protected int firstLevelTTL -
secondLevelTTL
protected int secondLevelTTL -
blobProviderId
-
defaultBlobProviderId
-
absoluteMaxSize
protected long absoluteMaxSize -
targetMaxSize
protected long targetMaxSize
-
-
Constructor Details
-
MongoDBTransientStore
public MongoDBTransientStore()
-
-
Method Details
-
init
Description copied from interface:TransientStoreProvider
Initializes the store from the givenconfig
.- Specified by:
init
in interfaceTransientStoreProvider
-
getColl
protected com.mongodb.client.MongoCollection<org.bson.Document> getColl() -
shutdown
public void shutdown()Description copied from interface:TransientStoreProvider
Shuts down the store.- Specified by:
shutdown
in interfaceTransientStoreProvider
-
keyStream
Description copied from interface:TransientStoreProvider
Returns aStream
of keys for all entries.- Specified by:
keyStream
in interfaceTransientStoreProvider
-
getStorageSize
public long getStorageSize()Description copied from interface:TransientStoreProvider
Returns the size (in bytes) of the disk storage used for blobs.- Specified by:
getStorageSize
in interfaceTransientStoreProvider
- Returns:
- the number of bytes used by stored blobs
-
doGC
public void doGC()Description copied from interface:TransientStoreProvider
Runs garbage collecting to delete the file system resources that are associated with entries that were removed.- Specified by:
doGC
in interfaceTransientStoreProvider
-
removeAll
public void removeAll()Description copied from interface:TransientStoreProvider
Removes all entries from the store.- Specified by:
removeAll
in interfaceTransientStoreProvider
-
exists
Description copied from interface:TransientStore
Returnstrue
if an entry exists with the givenkey
.- Specified by:
exists
in interfaceTransientStore
-
putParameter
Description copied from interface:TransientStore
Setsparameter
tovalue
in the entry with the givenkey
.If entry does not exist a new entry is created. If
parameter
already exists in the entry it is overwritten.- Specified by:
putParameter
in interfaceTransientStore
-
getParameter
Description copied from interface:TransientStore
Gets the value ofparameter
in the entry with the givenkey
.Returns
null
if entry or parameter does not exist.- Specified by:
getParameter
in interfaceTransientStore
-
deSerializeValue
-
serializeValue
-
putParameters
Description copied from interface:TransientStore
Putsparameters
in the entry with the givenkey
. Overwrites any existing parameter in the entry.If entry does not exist a new entry is created.
- Specified by:
putParameters
in interfaceTransientStore
-
getParameters
Description copied from interface:TransientStore
Gets values of the parameters in the entry with the givenkey
.Returns
null
if entry does not exist.- Specified by:
getParameters
in interfaceTransientStore
-
putBlobs
Description copied from interface:TransientStore
Associates the givenblobs
with the entry with the givenkey
.If entry does not exist a new entry is created.
- Specified by:
putBlobs
in interfaceTransientStore
-
getBlobs
Description copied from interface:TransientStore
Gets the blobs associated with the entry with the givenkey
.Returns
null
if entry does not exist.- Specified by:
getBlobs
in interfaceTransientStore
-
getSize
Description copied from interface:TransientStore
Returns the size of the blobs associated with the entry with the givenkey
or-1
if entry does not exist.- Specified by:
getSize
in interfaceTransientStore
-
isCompleted
Description copied from interface:TransientStore
Returnstrue
if the entry with the givenkey
is ready.- Specified by:
isCompleted
in interfaceTransientStore
-
setCompleted
Description copied from interface:TransientStore
Marks the entry with the givenkey
as ready.If entry does not exist a new entry is created.
- Specified by:
setCompleted
in interfaceTransientStore
-
setTTL
protected void setTTL(org.bson.Document entry, int ttlSeconds) -
createEntry
-
remove
Description copied from interface:TransientStore
Removes entry with the givenkey
.Has no effect if entry does not exist.
- Specified by:
remove
in interfaceTransientStore
-
release
Description copied from interface:TransientStore
Informs the store that the entry with the givenkey
can be released if TTL or GC parameters require to do some cleanup.Has no effect if entry does not exist.
- Specified by:
release
in interfaceTransientStore
-
getBlobProvider
-