public class DataStoreBlobStore extends 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 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(File f,
String name)
Adds the root record.
|
void |
addMetadataRecord(InputStream stream,
String name)
Adds the root record.
|
DataRecord |
addRecord(InputStream stream)
Creates a new data record.
|
DataRecord |
addRecord(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 String uploadToken) |
long |
countDeleteChunks(List<String> chunkIds,
long maxLastModifiedTime)
Deletes the blobs with the given ids.
|
void |
deleteAllMetadataRecords(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(List<String> chunkIds,
long maxLastModifiedTime)
Deletes the blobs with the given ids.
|
boolean |
deleteMetadataRecord(String name)
Deletes the root record represented by the given parameters.
|
Iterator<String> |
getAllChunkIds(long maxLastModifiedTime)
Gets all the identifiers.
|
Iterator<DataIdentifier> |
getAllIdentifiers()
Get all identifiers.
|
List<DataRecord> |
getAllMetadataRecords(String prefix)
Gets the all root records.
|
Iterator<DataRecord> |
getAllRecords()
Retrieved an iterator over all DataRecords.
|
String |
getBlobId(@NotNull String reference)
Returns the blobId that referred by the given binary reference.
|
long |
getBlobLength(String encodedBlobId)
Get the length of the blob.
|
long |
getBlockSizeMin()
Get the minimum block size (if there is any).
|
CacheStats |
getCacheStats() |
DataStore |
getDataStore() |
@Nullable URI |
getDownloadURI(@NotNull Blob blob,
@NotNull org.apache.jackrabbit.oak.api.blob.BlobDownloadOptions downloadOptions) |
InputStream |
getInputStream(String encodedBlobId)
Returns a new stream for given blobId.
|
DataRecord |
getMetadataRecord(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(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.
|
String |
getReference(@NotNull String encodedBlobId)
Returns a secure reference to blob referred by blobid, or
null if no such
reference is available. |
String |
getRepositoryId()
Returns the repository id (identifier for the repository in the DataStore)
|
@Nullable BlobTracker |
getTracker()
Gets the traker registered in the data store.
|
SharedDataStore.Type |
getType()
Gets the type.
|
void |
init(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(String name)
Checks if the metadata record with the name exists
|
int |
readBlob(String encodedBlobId,
long pos,
byte[] buff,
int off,
int length)
Read a number of bytes from a blob.
|
Iterator<String> |
resolveChunks(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 |
setRepositoryId(String repositoryId)
Sets the repository id to identify repository in the DataStore
|
void |
startMark()
Start the mark phase.
|
int |
sweep()
Remove all unused blocks.
|
String |
toString() |
void |
updateModifiedDateOnAccess(long before)
From now on, update the modified date of an object even when accessing it.
|
String |
writeBlob(InputStream stream)
Write a blob from an input stream.
|
String |
writeBlob(InputStream stream,
BlobOptions options)
Write a blob from an input stream with specified options.
|
String |
writeBlob(String tempFileName)
Write a blob from a temporary file.
|
public static final int DEFAULT_CACHE_SIZE
public static final 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
DataStoregetRecordIfStored in interface DataStoreidentifier - data identifierDataStoreException - if the data store could not be accessedpublic DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
DataStoregetRecord in interface DataStoreidentifier - data identifierDataStoreException - if the data store could not be accessed,
or if the given identifier is invalidpublic DataRecord getRecordFromReference(String reference) throws DataStoreException
DataStorenull if the reference is invalid, for example if it
points to a record that does not exist.getRecordFromReference in interface DataStorereference - binary referencenullDataStoreException - if the data store could not be accessedpublic DataRecord addRecord(InputStream stream) throws DataStoreException
DataStoreThe 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 DataStorestream - binary streamDataStoreException - if the data store could not be accessedpublic void updateModifiedDateOnAccess(long before)
DataStoreupdateModifiedDateOnAccess in interface DataStorebefore - - update the modified date to the current time if it is older than this valuepublic int deleteAllOlderThan(long min)
throws DataStoreException
DataStoredeleteAllOlderThan in interface DataStoremin - the minimum timeDataStoreExceptionpublic Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
DataStoregetAllIdentifiers in interface DataStoreDataStoreException - if the list could not be readpublic void init(String homeDir) throws RepositoryException
DataStoreinit in interface DataStorehomeDir - the home directory of the repositoryRepositoryExceptionpublic int getMinRecordLength()
DataStoregetMinRecordLength in interface DataStorepublic void close()
throws DataStoreException
DataStoreclose in interface AutoCloseableclose in interface DataStoreDataStoreException - if a problem occurredpublic String writeBlob(InputStream stream) throws IOException
BlobStorewriteBlob in interface BlobStorestream - the input streamIOExceptionpublic String writeBlob(InputStream stream, BlobOptions options) throws IOException
BlobStorewriteBlob in interface BlobStorestream - the input stream to writeoptions - the options to useIOExceptionpublic int readBlob(String encodedBlobId, long pos, byte[] buff, int off, int length) throws IOException
BlobStorereadBlob in interface BlobStoreencodedBlobId - the blob idpos - the position within the blobbuff - the target byte arrayoff - the offset within the target arraylength - the number of bytes to readIOExceptionpublic long getBlobLength(String encodedBlobId) throws IOException
BlobStoregetBlobLength in interface BlobStoreencodedBlobId - the blob idIOExceptionpublic String getBlobId(@NotNull @NotNull String reference)
BlobStorenull if the reference is invalid, for example if it
points to a blob that does not exist.public String getReference(@NotNull @NotNull String encodedBlobId)
BlobStorenull if no such
reference is available.getReference in interface BlobStoreencodedBlobId - blobId referring the blob for which reference is requirednullpublic InputStream getInputStream(String encodedBlobId) throws IOException
BlobStoreread
return the same sequence of bytes as long as neither call throws
an exception.getInputStream in interface BlobStoreencodedBlobId - the blob idIOExceptionpublic void setBlockSize(int x)
GarbageCollectableBlobStoresetBlockSize in interface GarbageCollectableBlobStorex - the block size in bytes.public String writeBlob(String tempFileName) throws IOException
GarbageCollectableBlobStorewriteBlob in interface GarbageCollectableBlobStoretempFileName - the temporary file nameIOExceptionpublic int sweep()
throws IOException
GarbageCollectableBlobStoresweep in interface GarbageCollectableBlobStoreIOExceptionpublic void startMark()
throws IOException
GarbageCollectableBlobStorestartMark in interface GarbageCollectableBlobStoreIOExceptionpublic void clearInUse()
DataStoreclearInUse in interface DataStoreclearInUse in interface GarbageCollectableBlobStorepublic void clearCache()
GarbageCollectableBlobStoreclearCache in interface GarbageCollectableBlobStorepublic long getBlockSizeMin()
GarbageCollectableBlobStoregetBlockSizeMin in interface GarbageCollectableBlobStorepublic Iterator<String> getAllChunkIds(long maxLastModifiedTime) throws Exception
GarbageCollectableBlobStoregetAllChunkIds in interface GarbageCollectableBlobStoremaxLastModifiedTime - the max last modified time to consider for retrieval,
with the special value '0' meaning no filtering by timeException - the exceptionpublic boolean deleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception
GarbageCollectableBlobStoredeleteChunks in interface GarbageCollectableBlobStorechunkIds - the chunk idsmaxLastModifiedTime - the max last modified time to consider for retrieval,
with the special value '0' meaning no filtering by timeException - the exceptionpublic long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception
GarbageCollectableBlobStorecountDeleteChunks in interface GarbageCollectableBlobStorechunkIds - the chunk idsmaxLastModifiedTime - the max last modified time to consider for retrieval,
with the special value '0' meaning no filtering by timeException - the exceptionpublic Iterator<String> resolveChunks(String blobId) throws IOException
GarbageCollectableBlobStoreresolveChunks in interface GarbageCollectableBlobStoreblobId - the blob idIOException - Signals that an I/O exception has occurred.public void addMetadataRecord(InputStream stream, String name) throws DataStoreException
SharedDataStoreaddMetadataRecord in interface SharedDataStorestream - the streamname - the name of the root recordDataStoreException - the data store exceptionpublic void addMetadataRecord(File f, String name) throws DataStoreException
SharedDataStoreaddMetadataRecord in interface SharedDataStoref - the filename - the name of the root recordDataStoreException - the data store exceptionpublic DataRecord getMetadataRecord(String name)
SharedDataStoregetMetadataRecord in interface SharedDataStorename - the name of the recordpublic boolean metadataRecordExists(String name)
SharedDataStoremetadataRecordExists in interface SharedDataStorepublic List<DataRecord> getAllMetadataRecords(String prefix)
SharedDataStoregetAllMetadataRecords in interface SharedDataStorepublic boolean deleteMetadataRecord(String name)
SharedDataStoredeleteMetadataRecord in interface SharedDataStorename - the name of the root recordpublic void deleteAllMetadataRecords(String prefix)
SharedDataStoredeleteAllMetadataRecords in interface SharedDataStoreprefix - metadata type identifierpublic void setRepositoryId(String repositoryId) throws DataStoreException
SharedDataStoresetRepositoryId in interface SharedDataStoreDataStoreExceptionpublic String getRepositoryId()
SharedDataStoregetRepositoryId in interface SharedDataStorepublic Iterator<DataRecord> getAllRecords() throws DataStoreException
SharedDataStoregetAllRecords in interface SharedDataStoreDataStoreExceptionpublic DataRecord getRecordForId(DataIdentifier identifier) throws DataStoreException
SharedDataStoregetRecordForId in interface SharedDataStoreidentifier - the if of the recordDataStoreExceptionpublic SharedDataStore.Type getType()
SharedDataStoregetType in interface SharedDataStorepublic DataRecord addRecord(InputStream input, BlobOptions options) throws DataStoreException
TypedDataStoreaddRecord in interface TypedDataStoreDataStoreExceptionpublic DataStore getDataStore()
public CacheStats getCacheStats()
public void setMaxCachedBinarySize(int maxCachedBinarySize)
public void setBlobStatsCollector(BlobStatsCollector stats)
public void addTracker(BlobTracker tracker)
BlobTrackingStoreaddTracker in interface BlobTrackingStore@Nullable public @Nullable BlobTracker getTracker()
BlobTrackingStoregetTracker in interface BlobTrackingStore@Nullable
public @Nullable org.apache.jackrabbit.oak.api.blob.BlobUpload initiateBlobUpload(long maxUploadSizeInBytes,
int maxNumberOfURIs)
throws IllegalArgumentException
initiateBlobUpload in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProviderIllegalArgumentException@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
IllegalArgumentException@Nullable public @Nullable Blob completeBlobUpload(@NotNull @NotNull String uploadToken) throws IllegalArgumentException
completeBlobUpload in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProviderIllegalArgumentExceptionCopyright © 2010 - 2020 Adobe. All Rights Reserved