public class DataStoreBlobStore extends java.lang.Object implements DataStore, BlobStore, GarbageCollectableBlobStore, BlobTrackingStore, TypedDataStore, org.apache.jackrabbit.oak.api.blob.BlobAccessProvider
DataStore.getMinRecordLength()
Modifier and Type | Class and Description |
---|---|
static class |
DataStoreBlobStore.BlobId |
SharedDataStore.Type
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CACHE_SIZE |
static java.lang.String |
MEM_CACHE_NAME |
Constructor and Description |
---|
DataStoreBlobStore(DataStore delegate) |
DataStoreBlobStore(DataStore delegate,
boolean encodeLengthInId) |
DataStoreBlobStore(DataStore delegate,
boolean encodeLengthInId,
int cacheSizeInMB) |
Modifier and Type | Method and Description |
---|---|
void |
addMetadataRecord(java.io.File f,
java.lang.String name)
Adds the root record.
|
void |
addMetadataRecord(java.io.InputStream stream,
java.lang.String name)
Adds the root record.
|
DataRecord |
addRecord(java.io.InputStream stream)
Creates a new data record.
|
DataRecord |
addRecord(java.io.InputStream input,
BlobOptions options)
Add a record with specified options.
|
void |
addTracker(BlobTracker tracker)
Registers a tracker in the data store.
|
void |
clearCache()
Clear the cache.
|
void |
clearInUse()
Clear the in-use list.
|
void |
close()
Close the data store
|
@Nullable Blob |
completeBlobUpload(@NotNull java.lang.String uploadToken) |
long |
countDeleteChunks(java.util.List<java.lang.String> chunkIds,
long maxLastModifiedTime)
Deletes the blobs with the given ids.
|
void |
deleteAllMetadataRecords(java.lang.String prefix)
Deletes all records matching the given prefix.
|
int |
deleteAllOlderThan(long min)
Delete objects that have a modified date older than the specified date.
|
boolean |
deleteChunks(java.util.List<java.lang.String> chunkIds,
long maxLastModifiedTime)
Deletes the blobs with the given ids.
|
boolean |
deleteMetadataRecord(java.lang.String name)
Deletes the root record represented by the given parameters.
|
java.util.Iterator<java.lang.String> |
getAllChunkIds(long maxLastModifiedTime)
Gets all the identifiers.
|
java.util.Iterator<DataIdentifier> |
getAllIdentifiers()
Get all identifiers.
|
java.util.List<DataRecord> |
getAllMetadataRecords(java.lang.String prefix)
Gets the all root records.
|
java.util.Iterator<DataRecord> |
getAllRecords()
Retrieved an iterator over all DataRecords.
|
java.lang.String |
getBlobId(@NotNull java.lang.String reference)
Returns the blobId that referred by the given binary reference.
|
long |
getBlobLength(java.lang.String encodedBlobId)
Get the length of the blob.
|
long |
getBlockSizeMin()
Get the minimum block size (if there is any).
|
CacheStats |
getCacheStats() |
DataStore |
getDataStore() |
@Nullable java.net.URI |
getDownloadURI(@NotNull Blob blob,
@NotNull org.apache.jackrabbit.oak.api.blob.BlobDownloadOptions downloadOptions) |
java.io.InputStream |
getInputStream(java.lang.String encodedBlobId)
Returns a new stream for given blobId.
|
DataRecord |
getMetadataRecord(java.lang.String name)
Retrieves the metadata record with the given name
|
int |
getMinRecordLength()
Get the minimum size of an object that should be stored in this data store.
|
DataRecord |
getRecord(DataIdentifier identifier)
Returns the identified data record.
|
DataRecord |
getRecordForId(DataIdentifier identifier)
Retrieves the record for the given identifier
|
DataRecord |
getRecordFromReference(java.lang.String reference)
Returns the record that matches the given binary reference.
|
DataRecord |
getRecordIfStored(DataIdentifier identifier)
Check if a record for the given identifier exists, and return it if yes.
|
java.lang.String |
getReference(@NotNull java.lang.String encodedBlobId)
Returns a secure reference to blob referred by blobid, or
null if no such
reference is available. |
@Nullable BlobTracker |
getTracker()
Gets the traker registered in the data store.
|
SharedDataStore.Type |
getType()
Gets the type.
|
void |
init(java.lang.String homeDir)
Initialized the data store
|
@Nullable org.apache.jackrabbit.oak.api.blob.BlobUpload |
initiateBlobUpload(long maxUploadSizeInBytes,
int maxNumberOfURIs) |
@Nullable org.apache.jackrabbit.oak.api.blob.BlobUpload |
initiateBlobUpload(long maxUploadSizeInBytes,
int maxNumberOfURIs,
@NotNull org.apache.jackrabbit.oak.api.blob.BlobUploadOptions options) |
boolean |
metadataRecordExists(java.lang.String name)
Checks if the metadata record with the name exists
|
int |
readBlob(java.lang.String encodedBlobId,
long pos,
byte[] buff,
int off,
int length)
Read a number of bytes from a blob.
|
java.util.Iterator<java.lang.String> |
resolveChunks(java.lang.String blobId)
Resolve chunks stored in the blob store from the given Id.
|
void |
setBlobStatsCollector(BlobStatsCollector stats) |
void |
setBlockSize(int x)
Set the block size used by this blob store, if the blob store splits
binaries into blocks.
|
void |
setMaxCachedBinarySize(int maxCachedBinarySize) |
void |
startMark()
Start the mark phase.
|
int |
sweep()
Remove all unused blocks.
|
java.lang.String |
toString() |
void |
updateModifiedDateOnAccess(long before)
From now on, update the modified date of an object even when accessing it.
|
java.lang.String |
writeBlob(java.io.InputStream stream)
Write a blob from an input stream.
|
java.lang.String |
writeBlob(java.io.InputStream stream,
BlobOptions options)
Write a blob from an input stream with specified options.
|
java.lang.String |
writeBlob(java.lang.String tempFileName)
Write a blob from a temporary file.
|
public static final int DEFAULT_CACHE_SIZE
public static final java.lang.String MEM_CACHE_NAME
public DataStoreBlobStore(DataStore delegate)
public DataStoreBlobStore(DataStore delegate, boolean encodeLengthInId)
public DataStoreBlobStore(DataStore delegate, boolean encodeLengthInId, int cacheSizeInMB)
public DataRecord getRecordIfStored(DataIdentifier identifier) throws DataStoreException
DataStore
getRecordIfStored
in interface DataStore
identifier
- data identifierDataStoreException
- if the data store could not be accessedpublic DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
DataStore
getRecord
in interface DataStore
identifier
- data identifierDataStoreException
- if the data store could not be accessed,
or if the given identifier is invalidpublic DataRecord getRecordFromReference(java.lang.String reference) throws DataStoreException
DataStore
null
if the reference is invalid, for example if it
points to a record that does not exist.getRecordFromReference
in interface DataStore
reference
- binary referencenull
DataStoreException
- if the data store could not be accessedpublic DataRecord addRecord(java.io.InputStream stream) throws DataStoreException
DataStore
The given stream is consumed and not closed by this method. It is the responsibility of the caller to close the stream. A typical call pattern would be:
InputStream stream = ...; try { record = store.addRecord(stream); } finally { stream.close(); }
addRecord
in interface DataStore
stream
- binary streamDataStoreException
- if the data store could not be accessedpublic void updateModifiedDateOnAccess(long before)
DataStore
updateModifiedDateOnAccess
in interface DataStore
before
- - update the modified date to the current time if it is older than this valuepublic int deleteAllOlderThan(long min) throws DataStoreException
DataStore
deleteAllOlderThan
in interface DataStore
min
- the minimum timeDataStoreException
public java.util.Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
DataStore
getAllIdentifiers
in interface DataStore
DataStoreException
- if the list could not be readpublic void init(java.lang.String homeDir) throws RepositoryException
DataStore
init
in interface DataStore
homeDir
- the home directory of the repositoryRepositoryException
public int getMinRecordLength()
DataStore
getMinRecordLength
in interface DataStore
public void close() throws DataStoreException
DataStore
close
in interface java.lang.AutoCloseable
close
in interface DataStore
DataStoreException
- if a problem occurredpublic java.lang.String writeBlob(java.io.InputStream stream) throws java.io.IOException
BlobStore
public java.lang.String writeBlob(java.io.InputStream stream, BlobOptions options) throws java.io.IOException
BlobStore
public int readBlob(java.lang.String encodedBlobId, long pos, byte[] buff, int off, int length) throws java.io.IOException
BlobStore
public long getBlobLength(java.lang.String encodedBlobId) throws java.io.IOException
BlobStore
getBlobLength
in interface BlobStore
encodedBlobId
- the blob idjava.io.IOException
public java.lang.String getBlobId(@NotNull @NotNull java.lang.String reference)
BlobStore
null
if the reference is invalid, for example if it
points to a blob that does not exist.public java.lang.String getReference(@NotNull @NotNull java.lang.String encodedBlobId)
BlobStore
null
if no such
reference is available.getReference
in interface BlobStore
encodedBlobId
- blobId referring the blob for which reference is requirednull
public java.io.InputStream getInputStream(java.lang.String encodedBlobId) throws java.io.IOException
BlobStore
read
return the same sequence of bytes as long as neither call throws
an exception.getInputStream
in interface BlobStore
encodedBlobId
- the blob idjava.io.IOException
public void setBlockSize(int x)
GarbageCollectableBlobStore
setBlockSize
in interface GarbageCollectableBlobStore
x
- the block size in bytes.public java.lang.String writeBlob(java.lang.String tempFileName) throws java.io.IOException
GarbageCollectableBlobStore
writeBlob
in interface GarbageCollectableBlobStore
tempFileName
- the temporary file namejava.io.IOException
public int sweep() throws java.io.IOException
GarbageCollectableBlobStore
sweep
in interface GarbageCollectableBlobStore
java.io.IOException
public void startMark() throws java.io.IOException
GarbageCollectableBlobStore
startMark
in interface GarbageCollectableBlobStore
java.io.IOException
public void clearInUse()
DataStore
clearInUse
in interface DataStore
clearInUse
in interface GarbageCollectableBlobStore
public void clearCache()
GarbageCollectableBlobStore
clearCache
in interface GarbageCollectableBlobStore
public long getBlockSizeMin()
GarbageCollectableBlobStore
getBlockSizeMin
in interface GarbageCollectableBlobStore
public java.util.Iterator<java.lang.String> getAllChunkIds(long maxLastModifiedTime) throws java.lang.Exception
GarbageCollectableBlobStore
getAllChunkIds
in interface GarbageCollectableBlobStore
maxLastModifiedTime
- the max last modified time to consider for retrieval,
with the special value '0' meaning no filtering by timejava.lang.Exception
- the exceptionpublic boolean deleteChunks(java.util.List<java.lang.String> chunkIds, long maxLastModifiedTime) throws java.lang.Exception
GarbageCollectableBlobStore
deleteChunks
in interface GarbageCollectableBlobStore
chunkIds
- the chunk idsmaxLastModifiedTime
- the max last modified time to consider for retrieval,
with the special value '0' meaning no filtering by timejava.lang.Exception
- the exceptionpublic long countDeleteChunks(java.util.List<java.lang.String> chunkIds, long maxLastModifiedTime) throws java.lang.Exception
GarbageCollectableBlobStore
countDeleteChunks
in interface GarbageCollectableBlobStore
chunkIds
- the chunk idsmaxLastModifiedTime
- the max last modified time to consider for retrieval,
with the special value '0' meaning no filtering by timejava.lang.Exception
- the exceptionpublic java.util.Iterator<java.lang.String> resolveChunks(java.lang.String blobId) throws java.io.IOException
GarbageCollectableBlobStore
resolveChunks
in interface GarbageCollectableBlobStore
blobId
- the blob idjava.io.IOException
- Signals that an I/O exception has occurred.public void addMetadataRecord(java.io.InputStream stream, java.lang.String name) throws DataStoreException
SharedDataStore
addMetadataRecord
in interface SharedDataStore
stream
- the streamname
- the name of the root recordDataStoreException
- the data store exceptionpublic void addMetadataRecord(java.io.File f, java.lang.String name) throws DataStoreException
SharedDataStore
addMetadataRecord
in interface SharedDataStore
f
- the filename
- the name of the root recordDataStoreException
- the data store exceptionpublic DataRecord getMetadataRecord(java.lang.String name)
SharedDataStore
getMetadataRecord
in interface SharedDataStore
name
- the name of the recordpublic boolean metadataRecordExists(java.lang.String name)
SharedDataStore
metadataRecordExists
in interface SharedDataStore
public java.util.List<DataRecord> getAllMetadataRecords(java.lang.String prefix)
SharedDataStore
getAllMetadataRecords
in interface SharedDataStore
public boolean deleteMetadataRecord(java.lang.String name)
SharedDataStore
deleteMetadataRecord
in interface SharedDataStore
name
- the name of the root recordpublic void deleteAllMetadataRecords(java.lang.String prefix)
SharedDataStore
deleteAllMetadataRecords
in interface SharedDataStore
prefix
- metadata type identifierpublic java.util.Iterator<DataRecord> getAllRecords() throws DataStoreException
SharedDataStore
getAllRecords
in interface SharedDataStore
DataStoreException
public DataRecord getRecordForId(DataIdentifier identifier) throws DataStoreException
SharedDataStore
getRecordForId
in interface SharedDataStore
identifier
- the if of the recordDataStoreException
public SharedDataStore.Type getType()
SharedDataStore
getType
in interface SharedDataStore
public DataRecord addRecord(java.io.InputStream input, BlobOptions options) throws DataStoreException
TypedDataStore
addRecord
in interface TypedDataStore
DataStoreException
public java.lang.String toString()
toString
in class java.lang.Object
public DataStore getDataStore()
public CacheStats getCacheStats()
public void setMaxCachedBinarySize(int maxCachedBinarySize)
public void setBlobStatsCollector(BlobStatsCollector stats)
public void addTracker(BlobTracker tracker)
BlobTrackingStore
addTracker
in interface BlobTrackingStore
@Nullable public @Nullable BlobTracker getTracker()
BlobTrackingStore
getTracker
in interface BlobTrackingStore
@Nullable public @Nullable org.apache.jackrabbit.oak.api.blob.BlobUpload initiateBlobUpload(long maxUploadSizeInBytes, int maxNumberOfURIs) throws java.lang.IllegalArgumentException
initiateBlobUpload
in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProvider
java.lang.IllegalArgumentException
@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 java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
@Nullable public @Nullable Blob completeBlobUpload(@NotNull @NotNull java.lang.String uploadToken) throws java.lang.IllegalArgumentException
completeBlobUpload
in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProvider
java.lang.IllegalArgumentException
@Nullable public @Nullable java.net.URI getDownloadURI(@NotNull @NotNull Blob blob, @NotNull @NotNull org.apache.jackrabbit.oak.api.blob.BlobDownloadOptions downloadOptions)
getDownloadURI
in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProvider
Copyright © 2010 - 2020 Adobe. All Rights Reserved