Class DataStoreBlobStore
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore
-
- All Implemented Interfaces:
AutoCloseable,DataStore,org.apache.jackrabbit.oak.api.blob.BlobAccessProvider,BlobTrackingStore,TypedDataStore,SharedDataStore,org.apache.jackrabbit.oak.spi.blob.BlobStore,org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
public class DataStoreBlobStore extends Object implements DataStore, org.apache.jackrabbit.oak.spi.blob.BlobStore, org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore, BlobTrackingStore, TypedDataStore, org.apache.jackrabbit.oak.api.blob.BlobAccessProvider
BlobStore wrapper for DataStore. Wraps Jackrabbit 2 DataStore and expose them as BlobStores It also handles inlining binaries if there size is smaller thanDataStore.getMinRecordLength()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataStoreBlobStore.BlobId-
Nested classes/interfaces inherited from interface org.apache.jackrabbit.oak.plugins.blob.SharedDataStore
SharedDataStore.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.jackrabbit.guava.common.cache.LoadingCache<String,byte[]>cachestatic intDEFAULT_CACHE_SIZEprotected DataStoredelegatestatic StringMEM_CACHE_NAMEprotected org.apache.jackrabbit.oak.spi.blob.stats.BlobStatsCollectorstats
-
Constructor Summary
Constructors Constructor Description DataStoreBlobStore(DataStore delegate)DataStoreBlobStore(DataStore delegate, boolean encodeLengthInId)DataStoreBlobStore(DataStore delegate, boolean encodeLengthInId, int cacheSizeInMB)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMetadataRecord(File f, String name)Adds the root record.voidaddMetadataRecord(InputStream stream, String name)Adds the root record.DataRecordaddRecord(InputStream stream)DataRecordaddRecord(InputStream input, org.apache.jackrabbit.oak.spi.blob.BlobOptions options)Add a record with specified options.voidaddTracker(BlobTracker tracker)Registers a tracker in the data store.voidclearCache()voidclearInUse()voidclose()@Nullable org.apache.jackrabbit.oak.api.BlobcompleteBlobUpload(@NotNull String uploadToken)longcountDeleteChunks(List<String> chunkIds, long maxLastModifiedTime)voiddeleteAllMetadataRecords(String prefix)Deletes all records matching the given prefix.intdeleteAllOlderThan(long min)booleandeleteChunks(List<String> chunkIds, long maxLastModifiedTime)booleandeleteMetadataRecord(String name)Deletes the root record represented by the given parameters.protected StringextractBlobId(String encodedBlobId)Iterator<String>getAllChunkIds(long maxLastModifiedTime)Iterator<DataIdentifier>getAllIdentifiers()List<DataRecord>getAllMetadataRecords(String prefix)Gets the all root records.Iterator<DataRecord>getAllRecords()Retrieved an iterator over all DataRecords.StringgetBlobId(@NotNull String reference)longgetBlobLength(String encodedBlobId)longgetBlockSizeMin()org.apache.jackrabbit.oak.cache.CacheStatsgetCacheStats()protected DataRecordgetDataRecord(String blobId)DataStoregetDataStore()@Nullable URIgetDownloadURI(@NotNull org.apache.jackrabbit.oak.api.Blob blob, @NotNull org.apache.jackrabbit.oak.api.blob.BlobDownloadOptions downloadOptions)InputStreamgetInputStream(String encodedBlobId)DataRecordgetMetadataRecord(String name)Retrieves the metadata record with the given nameintgetMinRecordLength()DataRecordgetRecord(DataIdentifier identifier)DataRecordgetRecordForId(DataIdentifier identifier)Retrieves the record for the given identifierDataRecordgetRecordFromReference(String reference)DataRecordgetRecordIfStored(DataIdentifier identifier)StringgetReference(@NotNull String encodedBlobId)StringgetRepositoryId()Returns the repository id (identifier for the repository in the DataStore)protected InputStreamgetStream(String blobId)@Nullable BlobTrackergetTracker()Gets the traker registered in the data store.SharedDataStore.TypegetType()Gets the type.voidinit(String homeDir)@Nullable org.apache.jackrabbit.oak.api.blob.BlobUploadinitiateBlobUpload(long maxUploadSizeInBytes, int maxNumberOfURIs)@Nullable org.apache.jackrabbit.oak.api.blob.BlobUploadinitiateBlobUpload(long maxUploadSizeInBytes, int maxNumberOfURIs, @NotNull org.apache.jackrabbit.oak.api.blob.BlobUploadOptions options)booleanmetadataRecordExists(String name)Checks if the metadata record with the name existsintreadBlob(String encodedBlobId, long pos, byte[] buff, int off, int length)Iterator<String>resolveChunks(String blobId)voidsetBlobStatsCollector(org.apache.jackrabbit.oak.spi.blob.stats.BlobStatsCollector stats)voidsetBlockSize(int x)voidsetMaxCachedBinarySize(int maxCachedBinarySize)voidsetRepositoryId(String repositoryId)Sets the repository id to identify repository in the DataStorevoidstartMark()intsweep()StringtoString()voidupdateModifiedDateOnAccess(long before)StringwriteBlob(InputStream stream)StringwriteBlob(InputStream stream, org.apache.jackrabbit.oak.spi.blob.BlobOptions options)StringwriteBlob(String tempFileName)
-
-
-
Field Detail
-
delegate
protected final DataStore delegate
-
stats
protected org.apache.jackrabbit.oak.spi.blob.stats.BlobStatsCollector stats
-
cache
protected final org.apache.jackrabbit.guava.common.cache.LoadingCache<String,byte[]> cache
-
DEFAULT_CACHE_SIZE
public static final int DEFAULT_CACHE_SIZE
- See Also:
- Constant Field Values
-
MEM_CACHE_NAME
public static final String MEM_CACHE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRecordIfStored
public DataRecord getRecordIfStored(DataIdentifier identifier) throws DataStoreException
- Specified by:
getRecordIfStoredin interfaceDataStore- Throws:
DataStoreException
-
getRecord
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
- Specified by:
getRecordin interfaceDataStore- Throws:
DataStoreException
-
getRecordFromReference
public DataRecord getRecordFromReference(String reference) throws DataStoreException
- Specified by:
getRecordFromReferencein interfaceDataStore- Throws:
DataStoreException
-
addRecord
public DataRecord addRecord(InputStream stream) throws DataStoreException
- Specified by:
addRecordin interfaceDataStore- Throws:
DataStoreException
-
updateModifiedDateOnAccess
public void updateModifiedDateOnAccess(long before)
- Specified by:
updateModifiedDateOnAccessin interfaceDataStore
-
deleteAllOlderThan
public int deleteAllOlderThan(long min) throws DataStoreException- Specified by:
deleteAllOlderThanin interfaceDataStore- Throws:
DataStoreException
-
getAllIdentifiers
public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
- Specified by:
getAllIdentifiersin interfaceDataStore- Throws:
DataStoreException
-
init
public void init(String homeDir) throws RepositoryException
- Specified by:
initin interfaceDataStore- Throws:
RepositoryException
-
getMinRecordLength
public int getMinRecordLength()
- Specified by:
getMinRecordLengthin interfaceDataStore
-
close
public void close() throws DataStoreException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDataStore- Throws:
DataStoreException
-
writeBlob
public String writeBlob(InputStream stream) throws IOException
- Specified by:
writeBlobin interfaceorg.apache.jackrabbit.oak.spi.blob.BlobStore- Throws:
IOException
-
writeBlob
public String writeBlob(InputStream stream, org.apache.jackrabbit.oak.spi.blob.BlobOptions options) throws IOException
- Specified by:
writeBlobin interfaceorg.apache.jackrabbit.oak.spi.blob.BlobStore- Throws:
IOException
-
readBlob
public int readBlob(String encodedBlobId, long pos, byte[] buff, int off, int length) throws IOException
- Specified by:
readBlobin interfaceorg.apache.jackrabbit.oak.spi.blob.BlobStore- Throws:
IOException
-
getBlobLength
public long getBlobLength(String encodedBlobId) throws IOException
- Specified by:
getBlobLengthin interfaceorg.apache.jackrabbit.oak.spi.blob.BlobStore- Throws:
IOException
-
getBlobId
public String getBlobId(@NotNull @NotNull String reference)
- Specified by:
getBlobIdin interfaceorg.apache.jackrabbit.oak.spi.blob.BlobStore
-
getReference
public String getReference(@NotNull @NotNull String encodedBlobId)
- Specified by:
getReferencein interfaceorg.apache.jackrabbit.oak.spi.blob.BlobStore
-
getInputStream
public InputStream getInputStream(String encodedBlobId) throws IOException
- Specified by:
getInputStreamin interfaceorg.apache.jackrabbit.oak.spi.blob.BlobStore- Throws:
IOException
-
setBlockSize
public void setBlockSize(int x)
- Specified by:
setBlockSizein interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
-
writeBlob
public String writeBlob(String tempFileName) throws IOException
- Specified by:
writeBlobin interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore- Throws:
IOException
-
sweep
public int sweep() throws IOException- Specified by:
sweepin interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore- Throws:
IOException
-
startMark
public void startMark() throws IOException- Specified by:
startMarkin interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore- Throws:
IOException
-
clearInUse
public void clearInUse()
- Specified by:
clearInUsein interfaceDataStore- Specified by:
clearInUsein interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
-
clearCache
public void clearCache()
- Specified by:
clearCachein interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
-
getBlockSizeMin
public long getBlockSizeMin()
- Specified by:
getBlockSizeMinin interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
-
getAllChunkIds
public Iterator<String> getAllChunkIds(long maxLastModifiedTime) throws Exception
- Specified by:
getAllChunkIdsin interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore- Throws:
Exception
-
deleteChunks
public boolean deleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception
- Specified by:
deleteChunksin interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore- Throws:
Exception
-
countDeleteChunks
public long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception
- Specified by:
countDeleteChunksin interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore- Throws:
Exception
-
resolveChunks
public Iterator<String> resolveChunks(String blobId) throws IOException
- Specified by:
resolveChunksin interfaceorg.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore- Throws:
IOException
-
addMetadataRecord
public void addMetadataRecord(InputStream stream, String name) throws DataStoreException
Description copied from interface:SharedDataStoreAdds the root record.- Specified by:
addMetadataRecordin interfaceSharedDataStore- Parameters:
stream- the streamname- the name of the root record- Throws:
DataStoreException- the data store exception
-
addMetadataRecord
public void addMetadataRecord(File f, String name) throws DataStoreException
Description copied from interface:SharedDataStoreAdds the root record.- Specified by:
addMetadataRecordin interfaceSharedDataStore- Parameters:
f- the filename- the name of the root record- Throws:
DataStoreException- the data store exception
-
getMetadataRecord
public DataRecord getMetadataRecord(String name)
Description copied from interface:SharedDataStoreRetrieves the metadata record with the given name- Specified by:
getMetadataRecordin interfaceSharedDataStore- Parameters:
name- the name of the record- Returns:
-
metadataRecordExists
public boolean metadataRecordExists(String name)
Description copied from interface:SharedDataStoreChecks if the metadata record with the name exists- Specified by:
metadataRecordExistsin interfaceSharedDataStore- Returns:
-
getAllMetadataRecords
public List<DataRecord> getAllMetadataRecords(String prefix)
Description copied from interface:SharedDataStoreGets the all root records.- Specified by:
getAllMetadataRecordsin interfaceSharedDataStore- Returns:
- the all root records
-
deleteMetadataRecord
public boolean deleteMetadataRecord(String name)
Description copied from interface:SharedDataStoreDeletes the root record represented by the given parameters.- Specified by:
deleteMetadataRecordin interfaceSharedDataStore- Parameters:
name- the name of the root record- Returns:
- success/failure
-
deleteAllMetadataRecords
public void deleteAllMetadataRecords(String prefix)
Description copied from interface:SharedDataStoreDeletes all records matching the given prefix.- Specified by:
deleteAllMetadataRecordsin interfaceSharedDataStore- Parameters:
prefix- metadata type identifier
-
setRepositoryId
public void setRepositoryId(String repositoryId) throws DataStoreException
Description copied from interface:SharedDataStoreSets the repository id to identify repository in the DataStore- Specified by:
setRepositoryIdin interfaceSharedDataStore- Throws:
DataStoreException
-
getRepositoryId
public String getRepositoryId()
Description copied from interface:SharedDataStoreReturns the repository id (identifier for the repository in the DataStore)- Specified by:
getRepositoryIdin interfaceSharedDataStore- Returns:
- repository id
-
getAllRecords
public Iterator<DataRecord> getAllRecords() throws DataStoreException
Description copied from interface:SharedDataStoreRetrieved an iterator over all DataRecords.- Specified by:
getAllRecordsin interfaceSharedDataStore- Returns:
- iterator over DataRecords
- Throws:
DataStoreException
-
getRecordForId
public DataRecord getRecordForId(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedDataStoreRetrieves the record for the given identifier- Specified by:
getRecordForIdin interfaceSharedDataStore- Parameters:
identifier- the if of the record- Returns:
- data record
- Throws:
DataStoreException
-
getType
public SharedDataStore.Type getType()
Description copied from interface:SharedDataStoreGets the type.- Specified by:
getTypein interfaceSharedDataStore- Returns:
- the type
-
addRecord
public DataRecord addRecord(InputStream input, org.apache.jackrabbit.oak.spi.blob.BlobOptions options) throws DataStoreException
Description copied from interface:TypedDataStoreAdd a record with specified options.- Specified by:
addRecordin interfaceTypedDataStore- Returns:
- Throws:
DataStoreException
-
getDataStore
public DataStore getDataStore()
-
getCacheStats
public org.apache.jackrabbit.oak.cache.CacheStats getCacheStats()
-
setMaxCachedBinarySize
public void setMaxCachedBinarySize(int maxCachedBinarySize)
-
setBlobStatsCollector
public void setBlobStatsCollector(org.apache.jackrabbit.oak.spi.blob.stats.BlobStatsCollector stats)
-
addTracker
public void addTracker(BlobTracker tracker)
Description copied from interface:BlobTrackingStoreRegisters a tracker in the data store.- Specified by:
addTrackerin interfaceBlobTrackingStore
-
getTracker
@Nullable public @Nullable BlobTracker getTracker()
Description copied from interface:BlobTrackingStoreGets the traker registered in the data store.- Specified by:
getTrackerin interfaceBlobTrackingStore- Returns:
- tracker
-
getStream
protected InputStream getStream(String blobId) throws IOException
- Throws:
IOException
-
getDataRecord
protected DataRecord getDataRecord(String blobId) throws DataStoreException
- Throws:
DataStoreException
-
initiateBlobUpload
@Nullable public @Nullable org.apache.jackrabbit.oak.api.blob.BlobUpload initiateBlobUpload(long maxUploadSizeInBytes, int maxNumberOfURIs) throws IllegalArgumentException- Specified by:
initiateBlobUploadin interfaceorg.apache.jackrabbit.oak.api.blob.BlobAccessProvider- Throws:
IllegalArgumentException
-
initiateBlobUpload
@Nullable public @Nullable org.apache.jackrabbit.oak.api.blob.BlobUpload initiateBlobUpload(long maxUploadSizeInBytes, int maxNumberOfURIs, @NotNull @NotNull org.apache.jackrabbit.oak.api.blob.BlobUploadOptions options) throws IllegalArgumentException- Specified by:
initiateBlobUploadin interfaceorg.apache.jackrabbit.oak.api.blob.BlobAccessProvider- Throws:
IllegalArgumentException
-
completeBlobUpload
@Nullable public @Nullable org.apache.jackrabbit.oak.api.Blob completeBlobUpload(@NotNull @NotNull String uploadToken) throws IllegalArgumentException- Specified by:
completeBlobUploadin interfaceorg.apache.jackrabbit.oak.api.blob.BlobAccessProvider- Throws:
IllegalArgumentException
-
getDownloadURI
@Nullable public @Nullable URI getDownloadURI(@NotNull @NotNull org.apache.jackrabbit.oak.api.Blob blob, @NotNull @NotNull org.apache.jackrabbit.oak.api.blob.BlobDownloadOptions downloadOptions)
- Specified by:
getDownloadURIin interfaceorg.apache.jackrabbit.oak.api.blob.BlobAccessProvider
-
-