Class KeyValueBlobTransientStore
- All Implemented Interfaces:
TransientStore
,TransientStoreProvider
This transient store is configured with the following properties:
- keyValueStore: the name of the key/value store to use. If not provided, it defaults to "transient_" + the transient store name.
- blobProvider: the name of the blob provider to use. If not provided, it defaults to "transient_" + the transient store name.
- defaultBlobProvider: if the configured or defaulted blob provider doesn't exist, a namespaced copy of this one will be used instead. The default is "default".
The storage format is the following:
__blobsize__: storage size; because entries may expire without us being notified due to their TTL, this may be higher than the actual storage size entryKey.completed: "true" if completed, "false" if not; presence of this key marks entry existence entryKey.paraminfo: ["foo", "bar"] entryKey.param.foo: value for param foo entryKey.param.foo__format: "java" for java serializable format, otherwise string entryKey.param.bar: value for param bar etc. entryKey.bloblock: "true" if there is a blob read/write in progress, null otherwise entryKey.blobinfo: {"count": number of blobs, "size": storage size of the blobs} entryKey.blob.0: {"key": key in blob provider for first blob, "mimetype": MIME Type, "encoding": encoding, "filename": filename, "digest": digest} entryKey.blob.1: {...} same for second blob etc.
- Since:
- 9.3
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected static final int
protected String
static final String
static final String
static final String
static final String
static final String
protected String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected String
static final String
protected static final long
protected static final long
protected com.fasterxml.jackson.databind.ObjectMapper
static final String
protected String
protected int
TTL used to keep objects around a bit longer if there's space for them, for caching.static final String
static final String
static final String
protected long
protected int
Basic TTL for all entries.protected static final long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
acquireBlobLockOrThrow
(String key, KeyValueStore kvs) protected boolean
acquireLock
(BooleanSupplier tryAcquireOnce) protected void
addStorageSize
(long delta) Deprecated.since 11.1protected void
addStorageSize
(long delta, KeyValueStore kvs) void
atomicUpdate
(String key, Function<String, String> updateFunction, long ttl) Deprecated.since 11.1protected void
atomicUpdate
(String key, Function<String, String> updateFunction, long ttl, KeyValueStore kvs) protected void
Computes an exact value for the current storage size (sum of all blobs size).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
.getBlobKeys
(String key) Gets the blobs associated with the entry with the givenkey
.protected KeyValueStore
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.jsonToList
(String json) Returns aStream
of keys for all entries.protected void
markEntryExists
(String key) Deprecated.since 11.1protected void
markEntryExists
(String key, KeyValueStore kvs) 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.protected void
releaseBlobLock
(String key, KeyValueStore kvs) void
Removes entry with the givenkey
.void
Removes all entries from the store.protected void
removeBlobs
(String key) Deprecated.since 11.1protected void
removeBlobs
(String key, KeyValueStore kvs) protected void
removeCompleted
(String key) Deprecated.since 11.1protected void
removeCompleted
(String key, KeyValueStore kvs) protected void
removeParameters
(String key) Deprecated.since 11.1protected void
removeParameters
(String key, KeyValueStore kvs) void
setCompleted
(String key, boolean completed) Marks the entry with the givenkey
as ready.protected void
setReleaseTTL
(String key) void
shutdown()
Shuts down the store.protected String
protected boolean
tryAcquireBlobLock
(String key, KeyValueStore kvs) protected boolean
tryAcquireOnceBlobLock
(String key, KeyValueStore kvs) 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
-
SEP
- See Also:
-
STORAGE_SIZE
- See Also:
-
DOT_COMPLETED
- See Also:
-
DOT_PARAMINFO
- See Also:
-
DOT_PARAM_DOT
- See Also:
-
FORMAT
- See Also:
-
FORMAT_JAVA
- See Also:
-
DOT_BLOBLOCK
- Since:
- 11.1
- See Also:
-
DOT_BLOBINFO
- See Also:
-
COUNT
- See Also:
-
SIZE
- See Also:
-
DOT_BLOB_DOT
- See Also:
-
KEY
- See Also:
-
MIMETYPE
- See Also:
-
ENCODING
- See Also:
-
FILENAME
- See Also:
-
LENGTH
- See Also:
-
DIGEST
- See Also:
-
CONFIG_KEY_VALUE_STORE
- See Also:
-
CONFIG_BLOB_PROVIDER
- See Also:
-
CONFIG_DEFAULT_BLOB_PROVIDER
- Since:
- 11.1
- See Also:
-
CONFIG_DEFAULT_BLOB_PROVIDER_DEFAULT
- Since:
- 11.1
- See Also:
-
BLOB_LOCK_TTL
protected static final int BLOB_LOCK_TTL- Since:
- 11.1
- See Also:
-
LOCK_ACQUIRE_TIME_NANOS
protected static final long LOCK_ACQUIRE_TIME_NANOS- Since:
- 11.1
-
LOCK_EXPONENTIAL_BACKOFF_AFTER_NANOS
protected static final long LOCK_EXPONENTIAL_BACKOFF_AFTER_NANOS- Since:
- 11.1
-
WARN_DURATION_MS_THRESHOLD
protected static final long WARN_DURATION_MS_THRESHOLD- Since:
- 2021.17
- See Also:
-
name
-
keyValueStoreName
-
blobProviderId
-
defaultBlobProviderId
-
ttl
protected int ttlBasic TTL for all entries. -
releaseTTL
protected int releaseTTLTTL used to keep objects around a bit longer if there's space for them, for caching. -
targetMaxSize
protected long targetMaxSize -
absoluteMaxSize
protected long absoluteMaxSize -
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper -
LIST_STRING
-
MAP_STRING_STRING
-
-
Constructor Details
-
KeyValueBlobTransientStore
public KeyValueBlobTransientStore()
-
-
Method Details
-
init
Description copied from interface:TransientStoreProvider
Initializes the store from the givenconfig
.- Specified by:
init
in interfaceTransientStoreProvider
-
getKeyValueStore
-
getBlobProvider
-
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
-
addStorageSize
Deprecated.since 11.1 -
addStorageSize
-
computeStorageSize
protected void computeStorageSize()Computes an exact value for the current storage size (sum of all blobs size). THIS METHOD IS COSTLY.Does not take into account blob de-duplication that may be done by the blob provider.
Does not take into account blobs that still exist in the blob provider but are not referenced anymore (due to TTL expiration or GC not having been done).
-
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
-
jsonToList
-
jsonToMap
-
toJson
-
atomicUpdate
Deprecated.since 11.1 -
atomicUpdate
protected void atomicUpdate(String key, Function<String, String> updateFunction, long ttl, KeyValueStore kvs) -
exists
Description copied from interface:TransientStore
Returnstrue
if an entry exists with the givenkey
.- Specified by:
exists
in interfaceTransientStore
-
markEntryExists
Deprecated.since 11.1 -
markEntryExists
-
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
-
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
-
removeParameters
Deprecated.since 11.1 -
removeParameters
-
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
-
removeBlobs
Deprecated.since 11.1 -
removeBlobs
-
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
-
getBlobKeys
-
acquireBlobLockOrThrow
-
tryAcquireBlobLock
-
tryAcquireOnceBlobLock
-
releaseBlobLock
-
acquireLock
-
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
-
removeCompleted
Deprecated.since 11.1 -
removeCompleted
-
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
-
setReleaseTTL
-
remove
Description copied from interface:TransientStore
Removes entry with the givenkey
.Has no effect if entry does not exist.
- Specified by:
remove
in interfaceTransientStore
-