Class UploadStagingCache

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class UploadStagingCache
    extends java.lang.Object
    implements java.io.Closeable
    Cache for staging async uploads. This serves as a temporary cache for serving local requests till the time the upload has not been synced with the backend.

    The appropriate backend for this cache are wrapped in StagingUploader implementations.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String UPLOAD_STAGING_DIR  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static UploadStagingCache build​(java.io.File dir, java.io.File home, int uploadThreads, long size, org.apache.jackrabbit.oak.plugins.blob.StagingUploader uploader, @Nullable FileCache cache, StatisticsProvider statisticsProvider, @Nullable org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorService executor, @Nullable java.util.concurrent.ScheduledExecutorService scheduledExecutor, int purgeInterval, int retryInterval)  
      void close()  
      protected java.util.Iterator<java.lang.String> getAllIdentifiers()
      Returns all identifiers presently staged.
      @Nullable java.io.File getIfPresent​(java.lang.String key)
      Returns the File if present or null otherwise.
      DataStoreCacheStatsMBean getStats()
      Cache related stats
      protected void invalidate​(java.lang.String key)
      Invalidate called externally.
      org.apache.jackrabbit.guava.common.base.Optional<org.apache.jackrabbit.guava.common.util.concurrent.SettableFuture<java.lang.Integer>> put​(java.lang.String id, java.io.File input)
      Puts the file into the staging cache if possible.
      protected void setDownloadCache​(@Nullable FileCache downloadCache)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • UPLOAD_STAGING_DIR

        protected static final java.lang.String UPLOAD_STAGING_DIR
        See Also:
        Constant Field Values
    • Method Detail

      • build

        public static UploadStagingCache build​(java.io.File dir,
                                               java.io.File home,
                                               int uploadThreads,
                                               long size,
                                               org.apache.jackrabbit.oak.plugins.blob.StagingUploader uploader,
                                               @Nullable
                                               @Nullable FileCache cache,
                                               StatisticsProvider statisticsProvider,
                                               @Nullable
                                               @Nullable org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorService executor,
                                               @Nullable
                                               @Nullable java.util.concurrent.ScheduledExecutorService scheduledExecutor,
                                               int purgeInterval,
                                               int retryInterval)
      • put

        public org.apache.jackrabbit.guava.common.base.Optional<org.apache.jackrabbit.guava.common.util.concurrent.SettableFuture<java.lang.Integer>> put​(java.lang.String id,
                                                                                                                                                          java.io.File input)
        Puts the file into the staging cache if possible. Returns an optional SettableFuture if staged for upload otherwise empty.
        Parameters:
        id - the id of the file to be staged
        input - the file to be staged
        Returns:
        An Optional SettableFuture containing 1 if upload was successful, 0 if an existing id is already pending for upload
      • invalidate

        protected void invalidate​(java.lang.String key)
        Invalidate called externally.
        Parameters:
        key - to invalidate
      • getAllIdentifiers

        protected java.util.Iterator<java.lang.String> getAllIdentifiers()
        Returns all identifiers presently staged.
        Returns:
        iterator of all identifiers presently staged.
      • getIfPresent

        @Nullable
        public @Nullable java.io.File getIfPresent​(java.lang.String key)
        Returns the File if present or null otherwise. Any usage of the returned file should assert for its existence as the file could be purged from the file system once uploaded using the internal scheduled remove mechanism.
        Parameters:
        key - of the file to check
        Returns:
        a File object if found
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • setDownloadCache

        protected void setDownloadCache​(@Nullable
                                        @Nullable FileCache downloadCache)