Class DataStoreBlobStore

    • Constructor Detail

      • DataStoreBlobStore

        public DataStoreBlobStore​(DataStore delegate)
      • DataStoreBlobStore

        public DataStoreBlobStore​(DataStore delegate,
                                  boolean encodeLengthInId)
      • DataStoreBlobStore

        public DataStoreBlobStore​(DataStore delegate,
                                  boolean encodeLengthInId,
                                  int cacheSizeInMB)
    • Method Detail

      • getRecordIfStored

        public DataRecord getRecordIfStored​(DataIdentifier identifier)
                                     throws DataStoreException
        Description copied from interface: DataStore
        Check if a record for the given identifier exists, and return it if yes. If no record exists, this method returns null.
        Specified by:
        getRecordIfStored in interface DataStore
        Parameters:
        identifier - data identifier
        Returns:
        the record if found, and null if not
        Throws:
        DataStoreException - if the data store could not be accessed
      • getRecord

        public DataRecord getRecord​(DataIdentifier identifier)
                             throws DataStoreException
        Description copied from interface: DataStore
        Returns the identified data record. The given identifier should be the identifier of a previously saved data record. Since records are never removed, there should never be cases where the identified record is not found. Abnormal cases like that are treated as errors and handled by throwing an exception.
        Specified by:
        getRecord in interface DataStore
        Parameters:
        identifier - data identifier
        Returns:
        identified data record
        Throws:
        DataStoreException - if the data store could not be accessed, or if the given identifier is invalid
      • getRecordFromReference

        public DataRecord getRecordFromReference​(java.lang.String reference)
                                          throws DataStoreException
        Description copied from interface: DataStore
        Returns the record that matches the given binary reference. Returns null if the reference is invalid, for example if it points to a record that does not exist.
        Specified by:
        getRecordFromReference in interface DataStore
        Parameters:
        reference - binary reference
        Returns:
        matching record, or null
        Throws:
        DataStoreException - if the data store could not be accessed
      • addRecord

        public DataRecord addRecord​(java.io.InputStream stream)
                             throws DataStoreException
        Description copied from interface: DataStore
        Creates a new data record. The given binary stream is consumed and a binary record containing the consumed stream is created and returned. If the same stream already exists in another record, then that record is returned instead of creating a new one.

        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();
             }
         
        Specified by:
        addRecord in interface DataStore
        Parameters:
        stream - binary stream
        Returns:
        data record that contains the given stream
        Throws:
        DataStoreException - if the data store could not be accessed
      • updateModifiedDateOnAccess

        public void updateModifiedDateOnAccess​(long before)
        Description copied from interface: DataStore
        From now on, update the modified date of an object even when accessing it. Usually, the modified date is only updated when creating a new object, or when a new link is added to an existing object. When this setting is enabled, even getLength() will update the modified date.
        Specified by:
        updateModifiedDateOnAccess in interface DataStore
        Parameters:
        before - - update the modified date to the current time if it is older than this value
      • deleteAllOlderThan

        public int deleteAllOlderThan​(long min)
                               throws DataStoreException
        Description copied from interface: DataStore
        Delete objects that have a modified date older than the specified date.
        Specified by:
        deleteAllOlderThan in interface DataStore
        Parameters:
        min - the minimum time
        Returns:
        the number of data records deleted
        Throws:
        DataStoreException
      • getMinRecordLength

        public int getMinRecordLength()
        Description copied from interface: DataStore
        Get the minimum size of an object that should be stored in this data store. Depending on the overhead and configuration, each store may return a different value.
        Specified by:
        getMinRecordLength in interface DataStore
        Returns:
        the minimum size in bytes
      • writeBlob

        public java.lang.String writeBlob​(java.io.InputStream stream)
                                   throws java.io.IOException
        Description copied from interface: BlobStore
        Write a blob from an input stream. This method closes the input stream.
        Specified by:
        writeBlob in interface BlobStore
        Parameters:
        stream - the input stream
        Returns:
        the blob id
        Throws:
        java.io.IOException
      • writeBlob

        public java.lang.String writeBlob​(java.io.InputStream stream,
                                          BlobOptions options)
                                   throws java.io.IOException
        Description copied from interface: BlobStore
        Write a blob from an input stream with specified options. This method closes the input stream.
        Specified by:
        writeBlob in interface BlobStore
        Parameters:
        stream - the input stream to write
        options - the options to use
        Returns:
        Throws:
        java.io.IOException
      • readBlob

        public int readBlob​(java.lang.String encodedBlobId,
                            long pos,
                            byte[] buff,
                            int off,
                            int length)
                     throws java.io.IOException
        Description copied from interface: BlobStore
        Read a number of bytes from a blob.
        Specified by:
        readBlob in interface BlobStore
        Parameters:
        encodedBlobId - the blob id
        pos - the position within the blob
        buff - the target byte array
        off - the offset within the target array
        length - the number of bytes to read
        Returns:
        the number of bytes read
        Throws:
        java.io.IOException
      • getBlobLength

        public long getBlobLength​(java.lang.String encodedBlobId)
                           throws java.io.IOException
        Description copied from interface: BlobStore
        Get the length of the blob.
        Specified by:
        getBlobLength in interface BlobStore
        Parameters:
        encodedBlobId - the blob id
        Returns:
        the length
        Throws:
        java.io.IOException
      • getBlobId

        public java.lang.String getBlobId​(@NotNull
                                          @NotNull java.lang.String reference)
        Description copied from interface: BlobStore
        Returns the blobId that referred by the given binary reference. Returns null if the reference is invalid, for example if it points to a blob that does not exist.
        Specified by:
        getBlobId in interface BlobStore
        Parameters:
        reference - binary reference
        Returns:
        matching blobId, or null
      • getReference

        public java.lang.String getReference​(@NotNull
                                             @NotNull java.lang.String encodedBlobId)
        Description copied from interface: BlobStore
        Returns a secure reference to blob referred by blobid, or null if no such reference is available.
        Specified by:
        getReference in interface BlobStore
        Parameters:
        encodedBlobId - blobId referring the blob for which reference is required
        Returns:
        binary reference, or null
      • getInputStream

        public java.io.InputStream getInputStream​(java.lang.String encodedBlobId)
                                           throws java.io.IOException
        Description copied from interface: BlobStore
        Returns a new stream for given blobId. The streams returned from multiple calls to this method are byte wise equals. That is, subsequent calls to read return the same sequence of bytes as long as neither call throws an exception.
        Specified by:
        getInputStream in interface BlobStore
        Parameters:
        encodedBlobId - the blob id
        Returns:
        a new stream for given blobId
        Throws:
        java.io.IOException
      • setBlockSize

        public void setBlockSize​(int x)
        Description copied from interface: GarbageCollectableBlobStore
        Set the block size used by this blob store, if the blob store splits binaries into blocks. If not, this setting is ignored.
        Specified by:
        setBlockSize in interface GarbageCollectableBlobStore
        Parameters:
        x - the block size in bytes.
      • writeBlob

        public java.lang.String writeBlob​(java.lang.String tempFileName)
                                   throws java.io.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
        Parameters:
        tempFileName - the temporary file name
        Returns:
        the blob id
        Throws:
        java.io.IOException
      • clearInUse

        public void clearInUse()
        Description copied from interface: DataStore
        Clear the in-use list. This is only used for testing to make the the garbage collection think that objects are no longer in use.
        Specified by:
        clearInUse in interface DataStore
        Specified by:
        clearInUse in interface GarbageCollectableBlobStore
      • getAllChunkIds

        public java.util.Iterator<java.lang.String> getAllChunkIds​(long maxLastModifiedTime)
                                                            throws java.lang.Exception
        Description copied from interface: GarbageCollectableBlobStore
        Gets all the identifiers.
        Specified by:
        getAllChunkIds in interface GarbageCollectableBlobStore
        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
      • deleteChunks

        public boolean deleteChunks​(java.util.List<java.lang.String> chunkIds,
                                    long maxLastModifiedTime)
                             throws java.lang.Exception
        Description copied from interface: GarbageCollectableBlobStore
        Deletes the blobs with the given ids.
        Specified by:
        deleteChunks in interface GarbageCollectableBlobStore
        Parameters:
        chunkIds - the chunk ids
        maxLastModifiedTime - the max last modified time to consider for retrieval, with the special value '0' meaning no filtering by time
        Returns:
        true, if successful
        Throws:
        java.lang.Exception - the exception
      • countDeleteChunks

        public long countDeleteChunks​(java.util.List<java.lang.String> chunkIds,
                                      long maxLastModifiedTime)
                               throws java.lang.Exception
        Description copied from interface: GarbageCollectableBlobStore
        Deletes the blobs with the given ids.
        Specified by:
        countDeleteChunks in interface GarbageCollectableBlobStore
        Parameters:
        chunkIds - the chunk ids
        maxLastModifiedTime - 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
      • resolveChunks

        public java.util.Iterator<java.lang.String> resolveChunks​(java.lang.String blobId)
                                                           throws java.io.IOException
        Description copied from interface: GarbageCollectableBlobStore
        Resolve chunks stored in the blob store from the given Id. This will not return any chunks stored in-line in the id.
        Specified by:
        resolveChunks in interface GarbageCollectableBlobStore
        Parameters:
        blobId - the blob id
        Returns:
        the iterator
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • getMetadataRecord

        public DataRecord getMetadataRecord​(java.lang.String name)
        Description copied from interface: SharedDataStore
        Retrieves the metadata record with the given name
        Specified by:
        getMetadataRecord in interface SharedDataStore
        Parameters:
        name - the name of the record
        Returns:
      • metadataRecordExists

        public boolean metadataRecordExists​(java.lang.String name)
        Description copied from interface: SharedDataStore
        Checks if the metadata record with the name exists
        Specified by:
        metadataRecordExists in interface SharedDataStore
        Returns:
      • deleteMetadataRecord

        public boolean deleteMetadataRecord​(java.lang.String name)
        Description copied from interface: SharedDataStore
        Deletes the root record represented by the given parameters.
        Specified by:
        deleteMetadataRecord in interface SharedDataStore
        Parameters:
        name - the name of the root record
        Returns:
        success/failure
      • deleteAllMetadataRecords

        public void deleteAllMetadataRecords​(java.lang.String prefix)
        Description copied from interface: SharedDataStore
        Deletes all records matching the given prefix.
        Specified by:
        deleteAllMetadataRecords in interface SharedDataStore
        Parameters:
        prefix - metadata type identifier
      • getRepositoryId

        public java.lang.String getRepositoryId()
        Description copied from interface: SharedDataStore
        Returns the repository id (identifier for the repository in the DataStore)
        Specified by:
        getRepositoryId in interface SharedDataStore
        Returns:
        repository id
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getDataStore

        public DataStore getDataStore()
      • getCacheStats

        public CacheStats getCacheStats()
      • setMaxCachedBinarySize

        public void setMaxCachedBinarySize​(int maxCachedBinarySize)
      • initiateBlobUpload

        @Nullable
        public @Nullable org.apache.jackrabbit.oak.api.blob.BlobUpload initiateBlobUpload​(long maxUploadSizeInBytes,
                                                                                          int maxNumberOfURIs)
                                                                                   throws java.lang.IllegalArgumentException
        Specified by:
        initiateBlobUpload in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProvider
        Throws:
        java.lang.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 java.lang.IllegalArgumentException
        Specified by:
        initiateBlobUpload in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProvider
        Throws:
        java.lang.IllegalArgumentException
      • completeBlobUpload

        @Nullable
        public @Nullable Blob completeBlobUpload​(@NotNull
                                                 @NotNull java.lang.String uploadToken)
                                          throws java.lang.IllegalArgumentException
        Specified by:
        completeBlobUpload in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProvider
        Throws:
        java.lang.IllegalArgumentException
      • getDownloadURI

        @Nullable
        public @Nullable java.net.URI getDownloadURI​(@NotNull
                                                     @NotNull Blob blob,
                                                     @NotNull
                                                     @NotNull org.apache.jackrabbit.oak.api.blob.BlobDownloadOptions downloadOptions)
        Specified by:
        getDownloadURI in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProvider