Class FileBlobStore
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
-
- org.apache.jackrabbit.oak.spi.blob.FileBlobStore
-
- All Implemented Interfaces:
java.lang.AutoCloseable,org.apache.jackrabbit.oak.commons.cache.Cache.Backend<AbstractBlobStore.BlockId,AbstractBlobStore.Data>,BlobStore,GarbageCollectableBlobStore
public class FileBlobStore extends AbstractBlobStore
A file blob store.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
AbstractBlobStore.BlockId, AbstractBlobStore.Data
-
-
Field Summary
-
Fields inherited from class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
BLOCK_SIZE_LIMIT, HASH_ALGORITHM, inUse, TYPE_DATA, TYPE_HASH
-
-
Constructor Summary
Constructors Constructor Description FileBlobStore(java.lang.String dir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache()Clear the cache.longcountDeleteChunks(java.util.List<java.lang.String> chunkIds, long maxLastModifiedTime)Deletes the blobs with the given ids.java.util.Iterator<java.lang.String>getAllChunkIds(long maxLastModifiedTime)Gets all the identifiers.protected booleanisMarkEnabled()protected voidmark(AbstractBlobStore.BlockId id)protected byte[]readBlockFromBackend(AbstractBlobStore.BlockId id)Load the block from the storage backend.voidstartMark()Start the mark phase.protected voidstoreBlock(byte[] digest, int level, byte[] data)Store a block of data.intsweep()Remove all unused blocks.java.lang.StringwriteBlob(java.lang.String tempFilePath)Write a blob from a temporary file.-
Methods inherited from class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
clearInUse, close, deleteChunks, getBlobId, getBlobLength, getBlockSize, getBlockSizeMin, getInputStream, getOrCreateReferenceKey, getReference, getStatsCollector, load, mark, markInUse, readBlob, resolveChunks, setBlockSize, setBlockSizeMin, setReferenceKey, setReferenceKeyEncoded, setReferenceKeyPlainText, setStatsCollector, usesBlobId, writeBlob, writeBlob
-
-
-
-
Method Detail
-
writeBlob
public java.lang.String writeBlob(java.lang.String tempFilePath) throws java.io.IOExceptionDescription copied from interface:GarbageCollectableBlobStoreWrite a blob from a temporary file. The temporary file is removed afterwards. A file based blob stores might simply rename the file, so that no additional writes are necessary.- Specified by:
writeBlobin interfaceGarbageCollectableBlobStore- Overrides:
writeBlobin classAbstractBlobStore- Parameters:
tempFilePath- the temporary file name- Returns:
- the blob id
- Throws:
java.io.IOException
-
storeBlock
protected void storeBlock(byte[] digest, int level, byte[] data) throws java.io.IOExceptionDescription copied from class:AbstractBlobStoreStore a block of data.- Specified by:
storeBlockin classAbstractBlobStore- Parameters:
digest- the content hash (32 bytes)level- the indirection level (0 is for user data, 1 is a list of digests that point to user data, 2 is a list of digests that point to digests, and so on). This parameter is for informational use only, and it is not required to store it unless that's easy to achievedata- the data to be stored (the number of bytes is at most the block size)- Throws:
java.io.IOException
-
readBlockFromBackend
protected byte[] readBlockFromBackend(AbstractBlobStore.BlockId id) throws java.io.IOException
Description copied from class:AbstractBlobStoreLoad the block from the storage backend. Returns null if the block was not found.- Specified by:
readBlockFromBackendin classAbstractBlobStore- Parameters:
id- the block id- Returns:
- the block data, or null
- Throws:
java.io.IOException
-
startMark
public void startMark() throws java.io.IOExceptionDescription copied from interface:GarbageCollectableBlobStoreStart the mark phase.- Specified by:
startMarkin interfaceGarbageCollectableBlobStore- Specified by:
startMarkin classAbstractBlobStore- Throws:
java.io.IOException
-
isMarkEnabled
protected boolean isMarkEnabled()
- Specified by:
isMarkEnabledin classAbstractBlobStore
-
mark
protected void mark(AbstractBlobStore.BlockId id) throws java.io.IOException
- Specified by:
markin classAbstractBlobStore- Throws:
java.io.IOException
-
sweep
public int sweep() throws java.io.IOExceptionDescription copied from interface:GarbageCollectableBlobStoreRemove all unused blocks.- Specified by:
sweepin interfaceGarbageCollectableBlobStore- Specified by:
sweepin classAbstractBlobStore- Returns:
- the number of removed blocks
- Throws:
java.io.IOException
-
countDeleteChunks
public long countDeleteChunks(java.util.List<java.lang.String> chunkIds, long maxLastModifiedTime) throws java.lang.ExceptionDescription copied from interface:GarbageCollectableBlobStoreDeletes the blobs with the given ids.- Parameters:
chunkIds- the chunk idsmaxLastModifiedTime- the max last modified time to consider for retrieval, with the special value '0' meaning no filtering by time- Returns:
- long the count of successful deletions
- Throws:
java.lang.Exception- the exception
-
getAllChunkIds
public java.util.Iterator<java.lang.String> getAllChunkIds(long maxLastModifiedTime) throws java.lang.ExceptionDescription copied from interface:GarbageCollectableBlobStoreGets all the identifiers.- Parameters:
maxLastModifiedTime- the max last modified time to consider for retrieval, with the special value '0' meaning no filtering by time- Returns:
- the identifiers
- Throws:
java.lang.Exception- the exception
-
clearCache
public void clearCache()
Description copied from interface:GarbageCollectableBlobStoreClear the cache.
-
-