Package org.apache.jackrabbit.core.data
Class AsyncUploadCache
- java.lang.Object
-
- org.apache.jackrabbit.core.data.AsyncUploadCache
-
public class AsyncUploadCache extends java.lang.Object
This class holds all in progress uploads. This class contains two data structures, one isasyncUploadMap
which isMap
of file path vs lastModified of upload. The secondtoBeDeleted
isSet
of upload which is marked for delete, while it is already in progress. Before starting an asynchronous upload, it requires to invokeadd(String)
to add entry toasyncUploadMap
. After asynchronous upload completes, it requires to invokeremove(String)
to remove entry fromasyncUploadMap
Any modification to this class are immediately persisted to local file system.asyncUploadMap
is persisted to /homeDir
/PENDIND_UPLOAD_FILE
.toBeDeleted
is persisted to /homeDir
/TO_BE_DELETED_UPLOAD_FILE
. The /homeDir
refer to ${rep.home}.
-
-
Constructor Summary
Constructors Constructor Description AsyncUploadCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncUploadCacheResult
add(java.lang.String fileName)
This methods checks if file can be added toasyncUploadMap
.void
delete(java.lang.String fileName)
This methods deletes asynchronous upload for @param fileName if there exists asynchronous upload for @param fileName.java.util.Set<java.lang.String>
deleteOlderThan(long min)
Delete in progress asynchronous uploads which are older than @param min.java.util.Set<java.lang.String>
getAll()
This methods returns the in progress asynchronous uploads which are not marked for delete.long
getLastModified(java.lang.String fileName)
Returns lastModified fromasyncUploadMap
if found else returns 0.boolean
hasEntry(java.lang.String fileName, boolean touch)
This methos checks if asynchronous upload is in progress for @param fileName.void
init(java.lang.String homeDir, java.lang.String path, int asyncUploadLimit)
AsyncUploadCacheResult
remove(java.lang.String fileName)
This methods removes file (if found) fromasyncUploadMap
.void
reset()
-
-
-
Method Detail
-
add
public AsyncUploadCacheResult add(java.lang.String fileName) throws java.io.IOException
This methods checks if file can be added toasyncUploadMap
. If yes it adds toasyncUploadMap
andserializeAsyncUploadMap()
theasyncUploadMap
to disk.- Returns:
AsyncUploadCacheResult
if successfully added to asynchronous uploads it setsAsyncUploadCacheResult.setAsyncUpload(boolean)
to true else sets to false.- Throws:
java.io.IOException
-
remove
public AsyncUploadCacheResult remove(java.lang.String fileName) throws java.io.IOException
This methods removes file (if found) fromasyncUploadMap
. If file is found, it immediately serializes theasyncUploadMap
to disk. This method setsAsyncUploadCacheResult.setRequiresDelete(boolean)
to true, if asynchronous upload found to be intoBeDeleted
set i.e. marked for delete.- Throws:
java.io.IOException
-
getAll
public java.util.Set<java.lang.String> getAll()
This methods returns the in progress asynchronous uploads which are not marked for delete.
-
hasEntry
public boolean hasEntry(java.lang.String fileName, boolean touch) throws java.io.IOException
This methos checks if asynchronous upload is in progress for @param fileName. If @param touch is true, the lastModified is updated to current time.- Throws:
java.io.IOException
-
getLastModified
public long getLastModified(java.lang.String fileName)
Returns lastModified fromasyncUploadMap
if found else returns 0.
-
delete
public void delete(java.lang.String fileName) throws java.io.IOException
This methods deletes asynchronous upload for @param fileName if there exists asynchronous upload for @param fileName.- Throws:
java.io.IOException
-
deleteOlderThan
public java.util.Set<java.lang.String> deleteOlderThan(long min) throws java.io.IOException
Delete in progress asynchronous uploads which are older than @param min. This method leverage lastModified stored inasyncUploadMap
- Throws:
java.io.IOException
-
init
public void init(java.lang.String homeDir, java.lang.String path, int asyncUploadLimit) throws java.io.IOException, java.lang.ClassNotFoundException
- Parameters:
homeDir
- home directory of repository.path
- path of theLocalCache
asyncUploadLimit
- the maximum number of asynchronous uploads- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
reset
public void reset() throws java.io.IOException
- Throws:
java.io.IOException
-
-