Class LocalBlobStore
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.AbstractBlobStore
-
- org.nuxeo.ecm.core.blob.LocalBlobStore
-
- All Implemented Interfaces:
BlobStore
- Direct Known Subclasses:
AESBlobStore
public class LocalBlobStore extends AbstractBlobStore
Blob storage as files on a local filesystem. The actual storage path chosen for a given key is decided based on aPathStrategy.- Since:
- 11.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classLocalBlobStore.LocalBlobGarbageCollector-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.blob.BlobStore
BlobStore.OptionalOrUnknown<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected LocalBlobStore.LocalBlobGarbageCollectorgcprotected PathStrategypathStrategy-
Fields inherited from class org.nuxeo.ecm.core.blob.AbstractBlobStore
blobProviderId, BYTE_RANGE_SEP, keyStrategy, name
-
-
Constructor Summary
Constructors Constructor Description LocalBlobStore(String name, KeyStrategy keyStrategy, PathStrategy pathStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()INTERNAL (TESTS).protected StringcopyBlob(String key, LocalBlobStore sourceStore, String sourceKey, boolean atomicMove)Optimized file-to-file copy/move.protected StringcopyBlobGeneric(String key, BlobStore sourceStore, String sourceKey, boolean atomicMove)Generic copy/move to a local file.booleancopyBlobIsOptimized(BlobStore sourceStore)Checks if blob copy/move from another blob store to this one can be done efficiently.StringcopyOrMoveBlob(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.booleanexists(String key)Does a blob with the given key exist in the blob store.BinaryGarbageCollectorgetBinaryGarbageCollector()Returns the binary garbage collector (GC).PathgetDirectory()Get the root directory of the store.BlobStore.OptionalOrUnknown<Path>getFile(String key)Gets an already-existing file containing the blob for the given key, if present.PathStrategygetPathStrategy()protected BlobStore.OptionalOrUnknown<Path>getStoredFile(String key)BlobStore.OptionalOrUnknown<InputStream>getStream(String key)Gets the stream of the blob for the given key, if present.booleanreadBlob(String key, Path dest)Reads a blob based on its key into the given file.protected voidwrite(BlobWriteContext blobWriteContext, Path file)protected StringwriteBlobGeneric(BlobWriteContext blobWriteContext)Writes the blob without using any store-to-store optimization.-
Methods inherited from class org.nuxeo.ecm.core.blob.AbstractBlobStore
deleteBlob, getBlobKeyReplacement, getByteRangeFromKey, getKeyStrategy, getName, hasVersioning, logTrace, logTrace, logTrace, notifyAsyncDigest, randomLong, randomString, setByteRangeInKey, stripBlobKeyPrefix, stripBlobKeyVersionSuffix, transfer, transfer, transfer, unwrap, useAsyncDigest, writeBlob, writeBlob, writeBlobProperties, writeBlobUsingOptimizedCopy
-
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.BlobStore
copyBlob, hasDefaultStorageClass
-
-
-
-
Field Detail
-
pathStrategy
protected final PathStrategy pathStrategy
-
gc
protected final LocalBlobStore.LocalBlobGarbageCollector gc
-
-
Constructor Detail
-
LocalBlobStore
public LocalBlobStore(String name, KeyStrategy keyStrategy, PathStrategy pathStrategy)
-
-
Method Detail
-
getDirectory
public Path getDirectory()
Get the root directory of the store.- Since:
- 2023
-
getPathStrategy
public PathStrategy getPathStrategy()
- Since:
- 2023
-
writeBlobGeneric
protected String writeBlobGeneric(BlobWriteContext blobWriteContext) throws IOException
Description copied from class:AbstractBlobStoreWrites the blob without using any store-to-store optimization.- Overrides:
writeBlobGenericin classAbstractBlobStore- Throws:
IOException
-
write
protected void write(BlobWriteContext blobWriteContext, Path file) throws IOException
- Throws:
IOException
-
copyBlobIsOptimized
public boolean copyBlobIsOptimized(BlobStore sourceStore)
Description copied from interface:BlobStoreChecks if blob copy/move from another blob store to this one can be done efficiently.- Specified by:
copyBlobIsOptimizedin interfaceBlobStore- Overrides:
copyBlobIsOptimizedin classAbstractBlobStore- Parameters:
sourceStore- the source store- Returns:
trueif the copy/move can be done efficiently
-
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.
- 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
-
copyBlob
protected String copyBlob(String key, LocalBlobStore sourceStore, String sourceKey, boolean atomicMove) throws IOException
Optimized file-to-file copy/move.- Throws:
IOException
-
copyBlobGeneric
protected String copyBlobGeneric(String key, BlobStore sourceStore, String sourceKey, boolean atomicMove) throws IOException
Generic copy/move to a local file.- Throws:
IOException
-
getFile
public BlobStore.OptionalOrUnknown<Path> getFile(String key)
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.
- Parameters:
key- the blob key- Returns:
- the file containing the blob, or empty if the blob cannot be found, or unknown if no file is available locally
-
getStoredFile
protected BlobStore.OptionalOrUnknown<Path> getStoredFile(String key)
-
getStream
public BlobStore.OptionalOrUnknown<InputStream> getStream(String key) throws IOException
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.
- 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
public boolean readBlob(String key, Path dest) throws IOException
Description copied from interface:BlobStoreReads a blob based on its key into the given file.- Parameters:
key- the blob keydest- the file to use to store the fetched data- Returns:
trueif the file was fetched,falseif the file was not found- Throws:
IOException
-
deleteBlob
public void deleteBlob(String key)
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.- Parameters:
key- the blob key
-
exists
public boolean exists(String key)
Description copied from interface:BlobStoreDoes a blob with the given key exist in the blob store.The existence of the blob is checked in the store where the blob is effectively stored. Intermediate cache is ignored.
- Parameters:
key- the blob key- Returns:
- true if it exists in the blob store
-
clear
public void clear()
Description copied from interface:BlobStoreINTERNAL (TESTS). Clears the blob store of all its data.
-
getBinaryGarbageCollector
public BinaryGarbageCollector 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().- Returns:
- the binary GC
-
-