Class MongoBlobStore

  • All Implemented Interfaces:
    AutoCloseable, org.apache.jackrabbit.oak.commons.cache.Cache.Backend<org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.BlockId,​org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.Data>, org.apache.jackrabbit.oak.spi.blob.BlobStore, org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore

    public class MongoBlobStore
    extends org.apache.jackrabbit.oak.plugins.blob.CachingBlobStore
    Implementation of blob store for the MongoDB extending from CachingBlobStore. It saves blobs into a separate collection in MongoDB (not using GridFS) and it supports basic garbage collection. FIXME: -Do we need to create commands for retry etc.? -Not sure if this is going to work for multiple MKs talking to same MongoDB?
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore

        org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.BlockId, org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.Data
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String COLLECTION_BLOBS  
      • Fields inherited from class org.apache.jackrabbit.oak.plugins.blob.CachingBlobStore

        blobCacheSize, cache, DEFAULT_CACHE_SIZE, MEM_CACHE_NAME
      • Fields inherited from class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore

        BLOCK_SIZE_LIMIT, HASH_ALGORITHM, inUse, TYPE_DATA, TYPE_HASH
    • Constructor Summary

      Constructors 
      Constructor Description
      MongoBlobStore​(@NotNull com.mongodb.client.MongoDatabase db, long cacheSize, @Nullable DocumentNodeStoreBuilder<?> builder)
      Constructs a new MongoBlobStore
      MongoBlobStore​(com.mongodb.client.MongoDatabase db)
      Constructs a new MongoBlobStore
      MongoBlobStore​(com.mongodb.client.MongoDatabase db, long cacheSize)
      Constructs a new MongoBlobStore
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long countDeleteChunks​(List<String> chunkIds, long maxLastModifiedTime)  
      Iterator<String> getAllChunkIds​(long maxLastModifiedTime)  
      protected boolean isMarkEnabled()  
      protected void mark​(org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.BlockId blockId)  
      protected byte[] readBlockFromBackend​(org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.BlockId blockId)  
      void startMark()  
      protected void storeBlock​(byte[] digest, int level, byte[] data)  
      int sweep()  
      • Methods inherited from class org.apache.jackrabbit.oak.plugins.blob.CachingBlobStore

        clearCache, getBlobCacheSize, getCacheStats
      • Methods inherited from class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore

        clearInUse, close, deleteChunks, getBlobId, getBlobLength, getBlockSize, getBlockSizeMin, getInputStream, getOrCreateReferenceKey, getReference, getStatsCollector, load, mark, markInUse, readBlob, resolveChunks, setBlockSize, setBlockSizeMin, setReferenceKey, setReferenceKeyEncoded, setReferenceKeyPlainText, setStatsCollector, usesBlobId, writeBlob, writeBlob, writeBlob
    • Constructor Detail

      • MongoBlobStore

        public MongoBlobStore​(com.mongodb.client.MongoDatabase db)
        Constructs a new MongoBlobStore
        Parameters:
        db - the database
      • MongoBlobStore

        public MongoBlobStore​(com.mongodb.client.MongoDatabase db,
                              long cacheSize)
        Constructs a new MongoBlobStore
        Parameters:
        db - the database
        cacheSize - the cache size
      • MongoBlobStore

        public MongoBlobStore​(@NotNull
                              @NotNull com.mongodb.client.MongoDatabase db,
                              long cacheSize,
                              @Nullable
                              @Nullable DocumentNodeStoreBuilder<?> builder)
        Constructs a new MongoBlobStore
        Parameters:
        db - the database
        cacheSize - the cache size
        builder - DocumentNodeStoreBuilder, supplying further options
    • Method Detail

      • storeBlock

        protected void storeBlock​(byte[] digest,
                                  int level,
                                  byte[] data)
                           throws IOException
        Specified by:
        storeBlock in class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
        Throws:
        IOException
      • readBlockFromBackend

        protected byte[] readBlockFromBackend​(org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.BlockId blockId)
                                       throws Exception
        Specified by:
        readBlockFromBackend in class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
        Throws:
        Exception
      • startMark

        public void startMark()
                       throws IOException
        Specified by:
        startMark in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Specified by:
        startMark in class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
        Throws:
        IOException
      • isMarkEnabled

        protected boolean isMarkEnabled()
        Specified by:
        isMarkEnabled in class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
      • mark

        protected void mark​(org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore.BlockId blockId)
                     throws Exception
        Specified by:
        mark in class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
        Throws:
        Exception
      • sweep

        public int sweep()
                  throws IOException
        Specified by:
        sweep in interface org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore
        Specified by:
        sweep in class org.apache.jackrabbit.oak.spi.blob.AbstractBlobStore
        Throws:
        IOException
      • countDeleteChunks

        public long countDeleteChunks​(List<String> chunkIds,
                                      long maxLastModifiedTime)
                               throws Exception
        Throws:
        Exception