Class TransactionalBlobStore
- All Implemented Interfaces:
jakarta.transaction.Synchronization,BlobStore
Until the transaction is committed, blobs are stored in a transient store. Upon commit, they are sent to the permanent store.
It is important that a copy operation between the transient store and the permanent store be extremely fast and never fail, as it will be done during commit.
- Since:
- 11.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTransient data recording operations applied to a blob, to be executed on the permanent store at commit time.Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.blob.BlobStore
BlobStore.OptionalOrUnknown<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringfinal BlobStoreprotected final ThreadLocal<Map<String, TransactionalBlobStore.TransientInfo>> final BlobStoreFields inherited from class org.nuxeo.ecm.core.blob.AbstractBlobStore
blobProviderId, BYTE_RANGE_SEP, keyStrategy, name -
Constructor Summary
ConstructorsConstructorDescriptionTransactionalBlobStore(String blobProviderId, BlobStore store, BlobStore transientStore) TransactionalBlobStore(BlobStore store, BlobStore transientStore) Deprecated.since 11.5 -
Method Summary
Modifier and TypeMethodDescriptionvoidafterCompletion(int status) voidvoidclear()INTERNAL (TESTS).copyOrMoveBlob(String key, BlobStore sourceStore, String sourceKey, boolean atomicMove) Writes a file based on a key, as an optimized copy/move from a source in another compatible blob store.voiddeleteBlob(String key) Deletes a blob based on a key.Returns the binary garbage collector (GC).Gets an already-existing file containing the blob for the given key, if present.Gets the stream of the blob for the given key, if present.protected jakarta.transaction.Transactionprotected TransactionalBlobStore.TransientInfogetTransientInfo(String key) protected StringgetTransientKey(String key) booleanWhether this blob store has versioning.protected static booleanisDeleteMarker(String transientKey) protected voidputTransientKey(String key, String transientKey) protected voidputTransientUpdate(String key, BlobUpdateContext blobUpdateContext) booleanReads a blob based on its key into the given file.unwrap()If this blob store wraps another one, returns it, otherwise returns this.booleanWhether this blob store is configured for async digest computation.protected StringwriteBlobGeneric(BlobWriteContext blobWriteContext) Writes the blob without using any store-to-store optimization.voidwriteBlobProperties(BlobUpdateContext blobUpdateContext) Sets properties on a blob.Methods inherited from class org.nuxeo.ecm.core.blob.AbstractBlobStore
copyBlobIsOptimized, deleteBlob, getBlobKeyReplacement, getByteRangeFromKey, getKeyStrategy, getName, logTrace, logTrace, logTrace, notifyAsyncDigest, randomLong, randomString, setByteRangeInKey, stripBlobKeyPrefix, stripBlobKeyVersionSuffix, transfer, transfer, transfer, writeBlob, writeBlob, writeBlobUsingOptimizedCopyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.core.blob.BlobStore
copyBlob, exists, hasDefaultStorageClass
-
Field Details
-
store
-
transientStore
-
transientInfo
-
keysInActiveTransactions
-
DELETE_MARKER
- See Also:
-
-
Constructor Details
-
TransactionalBlobStore
Deprecated.since 11.5 -
TransactionalBlobStore
- Since:
- 11.5
-
-
Method Details
-
isDeleteMarker
-
getBinaryGarbageCollector
Description copied from interface:BlobStoreReturns the binary garbage collector (GC).Several calls to this method will return the same GC, so that its status can be monitored using
BinaryGarbageCollector.isInProgress().- Specified by:
getBinaryGarbageCollectorin interfaceBlobStore- Returns:
- the binary GC
-
hasVersioning
public boolean hasVersioning()Description copied from interface:BlobStoreWhether this blob store has versioning.With versioning, two writes may use the same key. The returned keys will include a different version number to distinguish the writes.
- Specified by:
hasVersioningin interfaceBlobStore- Overrides:
hasVersioningin classAbstractBlobStore
-
unwrap
Description copied from interface:BlobStoreIf this blob store wraps another one, returns it, otherwise returns this.- Specified by:
unwrapin interfaceBlobStore- Overrides:
unwrapin classAbstractBlobStore- Returns:
- the lowest-level blob store
-
writeBlobGeneric
Description copied from class:AbstractBlobStoreWrites the blob without using any store-to-store optimization.- Overrides:
writeBlobGenericin classAbstractBlobStore- Throws:
IOException
-
copyOrMoveBlob
public String copyOrMoveBlob(String key, BlobStore sourceStore, String sourceKey, boolean atomicMove) throws IOException Description copied from interface:BlobStoreWrites a file based on a key, as an optimized copy/move from a source in another compatible blob store.The target
keymay benull, which is a signal from the caller that it has determined that deduplication is enabled and async digest computation is enabled, but the needed digest hasn't been computed, so this method should either find the digest in an efficient way if it can, or otherwise trigger an async digest computation.If the copy/move is requested to be atomic, then the destination file is created atomically. In case of atomic move, in some stores the destination will be created atomically but the source will only be deleted afterwards.
The returned key may be different than the passed one when versioning is used.
- Specified by:
copyOrMoveBlobin interfaceBlobStore- Parameters:
key- the key; ornullif the store should choose it or trigger async digest computationsourceStore- the source storesourceKey- the source keyatomicMove-truefor an atomic move,falsefor a regular copy- Returns:
- the key of the copied/moved file, or
nullif copy/move failed - Throws:
IOException
-
useAsyncDigest
public boolean useAsyncDigest()Description copied from class:AbstractBlobStoreWhether this blob store is configured for async digest computation.- Overrides:
useAsyncDigestin classAbstractBlobStore
-
getFile
Description copied from interface:BlobStoreGets an already-existing file containing the blob for the given key, if present.Note that this method is best-effort, it may return unknown even though the blob exists in the store, it's just that it's not handily available locally in a file.
-
getStream
Description copied from interface:BlobStoreGets the stream of the blob for the given key, if present.Note that this method is best-effort, it may return unknown even though the blob exists in the store, it's just that it's not efficient to return it as a stream.
- Specified by:
getStreamin interfaceBlobStore- Parameters:
key- the blob key- Returns:
- the blob stream, or empty if the blob cannot be found, or unknown if no stream is efficiently available
- Throws:
IOException
-
readBlob
Description copied from interface:BlobStoreReads a blob based on its key into the given file.- Specified by:
readBlobin interfaceBlobStore- Parameters:
key- the blob keyfile- the file to use to store the fetched data- Returns:
trueif the file was fetched,falseif the file was not found- Throws:
IOException
-
writeBlobProperties
Description copied from interface:BlobStoreSets properties on a blob.- Specified by:
writeBlobPropertiesin interfaceBlobStore- Overrides:
writeBlobPropertiesin classAbstractBlobStore- Parameters:
blobUpdateContext- the blob update context- Throws:
IOException
-
deleteBlob
Description copied from interface:BlobStoreDeletes a blob based on a key. No error occurs if the blob does not exist.This method does not throw
IOException, but may log an error message.- Specified by:
deleteBlobin interfaceBlobStore- Parameters:
key- the blob key
-
clear
public void clear()Description copied from interface:BlobStoreINTERNAL (TESTS). Clears the blob store of all its data. -
getTransaction
protected jakarta.transaction.Transaction getTransaction() -
getTransientKey
-
putTransientKey
-
putTransientUpdate
-
getTransientInfo
-
beforeCompletion
public void beforeCompletion()- Specified by:
beforeCompletionin interfacejakarta.transaction.Synchronization
-
afterCompletion
public void afterCompletion(int status) - Specified by:
afterCompletionin interfacejakarta.transaction.Synchronization
-