org.apache.jackrabbit.oak.spi.blob
Class FileBlobStore

java.lang.Object
  extended by org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
      extended by org.apache.jackrabbit.oak.spi.blob.FileBlobStore
All Implemented Interfaces:
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, TYPE_HASH_COMPRESSED
 
Constructor Summary
FileBlobStore(String dir)
           
 
Method Summary
 void clearCache()
          Clear the cache.
 boolean deleteChunks(List<String> chunkIds, long maxLastModifiedTime)
          Deletes the blobs with the given ids.
 Iterator<String> getAllChunkIds(long maxLastModifiedTime)
          Gets all the identifiers.
protected  boolean isMarkEnabled()
           
protected  void mark(AbstractBlobStore.BlockId id)
           
protected  byte[] readBlockFromBackend(AbstractBlobStore.BlockId id)
          Load the block from the storage backend.
 void startMark()
          Start the mark phase.
protected  void storeBlock(byte[] digest, int level, byte[] data)
          Store a block of data.
 int sweep()
          Remove all unused blocks.
 String writeBlob(String tempFilePath)
          Write a blob from a temporary file.
 
Methods inherited from class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
clearInUse, getBlobId, getBlobLength, getBlockSize, getBlockSizeMin, getInputStream, getOrCreateReferenceKey, getReference, load, mark, markInUse, readBlob, resolveChunks, setBlockSize, setBlockSizeMin, setReferenceKey, setReferenceKeyEncoded, setReferenceKeyPlainText, usesBlobId, writeBlob
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileBlobStore

public FileBlobStore(String dir)
Method Detail

writeBlob

public String writeBlob(String tempFilePath)
                 throws IOException
Description copied from interface: GarbageCollectableBlobStore
Write 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:
writeBlob in interface GarbageCollectableBlobStore
Overrides:
writeBlob in class AbstractBlobStore
Parameters:
tempFilePath - the temporary file name
Returns:
the blob id
Throws:
IOException

storeBlock

protected void storeBlock(byte[] digest,
                          int level,
                          byte[] data)
                   throws IOException
Description copied from class: AbstractBlobStore
Store a block of data.

Specified by:
storeBlock in class AbstractBlobStore
Parameters:
digest - the content hash
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 achieve
data - the data to be stored
Throws:
IOException

readBlockFromBackend

protected byte[] readBlockFromBackend(AbstractBlobStore.BlockId id)
                               throws IOException
Description copied from class: AbstractBlobStore
Load the block from the storage backend. Returns null if the block was not found.

Specified by:
readBlockFromBackend in class AbstractBlobStore
Parameters:
id - the block id
Returns:
the block data, or null
Throws:
IOException

startMark

public void startMark()
               throws IOException
Description copied from interface: GarbageCollectableBlobStore
Start the mark phase.

Specified by:
startMark in interface GarbageCollectableBlobStore
Specified by:
startMark in class AbstractBlobStore
Throws:
IOException

isMarkEnabled

protected boolean isMarkEnabled()
Specified by:
isMarkEnabled in class AbstractBlobStore

mark

protected void mark(AbstractBlobStore.BlockId id)
             throws IOException
Specified by:
mark in class AbstractBlobStore
Throws:
IOException

sweep

public int sweep()
          throws IOException
Description copied from interface: GarbageCollectableBlobStore
Remove all unused blocks.

Specified by:
sweep in interface GarbageCollectableBlobStore
Specified by:
sweep in class AbstractBlobStore
Returns:
the number of removed blocks
Throws:
IOException

deleteChunks

public boolean deleteChunks(List<String> chunkIds,
                            long maxLastModifiedTime)
                     throws Exception
Description copied from interface: GarbageCollectableBlobStore
Deletes the blobs with the given ids.

Parameters:
chunkIds - the chunk ids
maxLastModifiedTime - the max last modified time to consider for retrieval
Returns:
true, if successful
Throws:
Exception - the exception

getAllChunkIds

public Iterator<String> getAllChunkIds(long maxLastModifiedTime)
                                throws Exception
Description copied from interface: GarbageCollectableBlobStore
Gets all the identifiers.

Parameters:
maxLastModifiedTime - the max last modified time to consider for retrieval
Returns:
the identifiers
Throws:
Exception - the exception

clearCache

public void clearCache()
Description copied from interface: GarbageCollectableBlobStore
Clear the cache.



Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.