Class DataStoreBlobStore

  • All Implemented Interfaces:
    java.lang.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 java.lang.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 than DataStore.getMinRecordLength()
    • 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<java.lang.String,​byte[]> cache
    • 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

      • init

        public void init​(java.lang.String homeDir)
                  throws javax.jcr.RepositoryException
        Specified by:
        init in interface DataStore
        Throws:
        javax.jcr.RepositoryException
      • writeBlob

        public java.lang.String writeBlob​(java.io.InputStream stream)
                                   throws java.io.IOException
        Specified by:
        writeBlob in interface org.apache.jackrabbit.oak.spi.blob.BlobStore
        Throws:
        java.io.IOException
      • writeBlob

        public java.lang.String writeBlob​(java.io.InputStream stream,
                                          org.apache.jackrabbit.oak.spi.blob.BlobOptions options)
                                   throws java.io.IOException
        Specified by:
        writeBlob in interface org.apache.jackrabbit.oak.spi.blob.BlobStore
        Throws:
        java.io.IOException
      • readBlob

        public int readBlob​(java.lang.String encodedBlobId,
                            long pos,
                            byte[] buff,
                            int off,
                            int length)
                     throws java.io.IOException
        Specified by:
        readBlob in interface org.apache.jackrabbit.oak.spi.blob.BlobStore
        Throws:
        java.io.IOException
      • getBlobLength

        public long getBlobLength​(java.lang.String encodedBlobId)
                           throws java.io.IOException
        Specified by:
        getBlobLength in interface org.apache.jackrabbit.oak.spi.blob.BlobStore
        Throws:
        java.io.IOException
      • getBlobId

        public java.lang.String getBlobId​(@NotNull
                                          @NotNull java.lang.String reference)
        Specified by:
        getBlobId in interface org.apache.jackrabbit.oak.spi.blob.BlobStore
      • getReference

        public java.lang.String getReference​(@NotNull
                                             @NotNull java.lang.String encodedBlobId)
        Specified by:
        getReference in interface org.apache.jackrabbit.oak.spi.blob.BlobStore
      • getInputStream

        public java.io.InputStream getInputStream​(java.lang.String encodedBlobId)
                                           throws java.io.IOException
        Specified by:
        getInputStream in interface org.apache.jackrabbit.oak.spi.blob.BlobStore
        Throws:
        java.io.IOException
      • setBlockSize

        public void setBlockSize​(int x)
        Specified by:
        setBlockSize in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
      • writeBlob

        public java.lang.String writeBlob​(java.lang.String tempFileName)
                                   throws java.io.IOException
        Specified by:
        writeBlob in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Throws:
        java.io.IOException
      • sweep

        public int sweep()
                  throws java.io.IOException
        Specified by:
        sweep in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Throws:
        java.io.IOException
      • startMark

        public void startMark()
                       throws java.io.IOException
        Specified by:
        startMark in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Throws:
        java.io.IOException
      • clearInUse

        public void clearInUse()
        Specified by:
        clearInUse in interface DataStore
        Specified by:
        clearInUse in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
      • clearCache

        public void clearCache()
        Specified by:
        clearCache in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
      • getBlockSizeMin

        public long getBlockSizeMin()
        Specified by:
        getBlockSizeMin in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
      • getAllChunkIds

        public java.util.Iterator<java.lang.String> getAllChunkIds​(long maxLastModifiedTime)
                                                            throws java.lang.Exception
        Specified by:
        getAllChunkIds in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Throws:
        java.lang.Exception
      • deleteChunks

        public boolean deleteChunks​(java.util.List<java.lang.String> chunkIds,
                                    long maxLastModifiedTime)
                             throws java.lang.Exception
        Specified by:
        deleteChunks in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Throws:
        java.lang.Exception
      • countDeleteChunks

        public long countDeleteChunks​(java.util.List<java.lang.String> chunkIds,
                                      long maxLastModifiedTime)
                               throws java.lang.Exception
        Specified by:
        countDeleteChunks in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Throws:
        java.lang.Exception
      • resolveChunks

        public java.util.Iterator<java.lang.String> resolveChunks​(java.lang.String blobId)
                                                           throws java.io.IOException
        Specified by:
        resolveChunks in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Throws:
        java.io.IOException
      • 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 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)
      • getStream

        protected java.io.InputStream getStream​(java.lang.String blobId)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • extractBlobId

        protected java.lang.String extractBlobId​(java.lang.String encodedBlobId)
      • 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 org.apache.jackrabbit.oak.api.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 org.apache.jackrabbit.oak.api.Blob blob,
                                                     @NotNull
                                                     @NotNull org.apache.jackrabbit.oak.api.blob.BlobDownloadOptions downloadOptions)
        Specified by:
        getDownloadURI in interface org.apache.jackrabbit.oak.api.blob.BlobAccessProvider