Package org.apache.jackrabbit.core.data
Class AsyncUploadCache
java.lang.Object
org.apache.jackrabbit.core.data.AsyncUploadCache
This class holds all in progress uploads. This class contains two data
structures, one is
asyncUploadMap which is Map
of file path vs lastModified of upload. The second toBeDeleted is
Set of upload which is marked for delete, while it is already
in progress. Before starting an asynchronous upload, it requires to invoke
add(String) to add entry to asyncUploadMap. After
asynchronous upload completes, it requires to invoke
remove(String) to remove entry from
asyncUploadMap 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 -
Method Summary
Modifier and TypeMethodDescriptionThis methods checks if file can be added toasyncUploadMap.voidThis methods deletes asynchronous upload for @param fileName if there exists asynchronous upload for @param fileName.deleteOlderThan(long min) Delete in progress asynchronous uploads which are older than @param min.getAll()This methods returns the in progress asynchronous uploads which are not marked for delete.longgetLastModified(String fileName) Returns lastModified fromasyncUploadMapif found else returns 0.booleanThis methos checks if asynchronous upload is in progress for @param fileName.voidThis methods removes file (if found) fromasyncUploadMap.voidreset()
-
Constructor Details
-
AsyncUploadCache
public AsyncUploadCache()
-
-
Method Details
-
add
This methods checks if file can be added toasyncUploadMap. If yes it adds toasyncUploadMapandserializeAsyncUploadMap()theasyncUploadMapto disk.- Returns:
AsyncUploadCacheResultif successfully added to asynchronous uploads it setsAsyncUploadCacheResult.setAsyncUpload(boolean)to true else sets to false.- Throws:
IOException
-
remove
This methods removes file (if found) fromasyncUploadMap. If file is found, it immediately serializes theasyncUploadMapto disk. This method setsAsyncUploadCacheResult.setRequiresDelete(boolean)to true, if asynchronous upload found to be intoBeDeletedset i.e. marked for delete.- Throws:
IOException
-
getAll
This methods returns the in progress asynchronous uploads which are not marked for delete. -
hasEntry
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:
IOException
-
getLastModified
Returns lastModified fromasyncUploadMapif found else returns 0. -
delete
This methods deletes asynchronous upload for @param fileName if there exists asynchronous upload for @param fileName.- Throws:
IOException
-
deleteOlderThan
Delete in progress asynchronous uploads which are older than @param min. This method leverage lastModified stored inasyncUploadMap- Throws:
IOException
-
init
public void init(String homeDir, String path, int asyncUploadLimit) throws IOException, ClassNotFoundException - Parameters:
homeDir- home directory of repository.path- path of theLocalCacheasyncUploadLimit- the maximum number of asynchronous uploads- Throws:
IOExceptionClassNotFoundException
-
reset
- Throws:
IOException
-