Class UploadStagingCache
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.blob.UploadStagingCache
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class UploadStagingCache extends Object implements 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
StagingUploaderimplementations.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringUPLOAD_STAGING_DIR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static UploadStagingCachebuild(File dir, File home, int uploadThreads, long size, org.apache.jackrabbit.oak.plugins.blob.StagingUploader uploader, @Nullable FileCache cache, org.apache.jackrabbit.oak.stats.StatisticsProvider statisticsProvider, @Nullable org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorService executor, @Nullable ScheduledExecutorService scheduledExecutor, int purgeInterval, int retryInterval)voidclose()protected Iterator<String>getAllIdentifiers()Returns all identifiers presently staged.@Nullable FilegetIfPresent(String key)Returns the File if present or null otherwise.DataStoreCacheStatsMBeangetStats()Cache related statsprotected voidinvalidate(String key)Invalidate called externally.Optional<org.apache.jackrabbit.guava.common.util.concurrent.SettableFuture<Integer>>put(String id, File input)Puts the file into the staging cache if possible.protected voidsetDownloadCache(@Nullable FileCache downloadCache)
-
-
-
Field Detail
-
UPLOAD_STAGING_DIR
protected static final String UPLOAD_STAGING_DIR
- See Also:
- Constant Field Values
-
-
Method Detail
-
build
public static UploadStagingCache build(File dir, File home, int uploadThreads, long size, org.apache.jackrabbit.oak.plugins.blob.StagingUploader uploader, @Nullable @Nullable FileCache cache, org.apache.jackrabbit.oak.stats.StatisticsProvider statisticsProvider, @Nullable @Nullable org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorService executor, @Nullable @Nullable ScheduledExecutorService scheduledExecutor, int purgeInterval, int retryInterval)
-
put
public Optional<org.apache.jackrabbit.guava.common.util.concurrent.SettableFuture<Integer>> put(String id, 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 stagedinput- 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(String key)
Invalidate called externally.- Parameters:
key- to invalidate
-
getAllIdentifiers
protected Iterator<String> getAllIdentifiers()
Returns all identifiers presently staged.- Returns:
- iterator of all identifiers presently staged.
-
getIfPresent
@Nullable public @Nullable File getIfPresent(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
-
getStats
public DataStoreCacheStatsMBean getStats()
Cache related stats- Returns:
- an instance of the
DataStoreCacheStatsMBean.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
setDownloadCache
protected void setDownloadCache(@Nullable @Nullable FileCache downloadCache)
-
-