org.apache.jackrabbit.core.data
Class AsyncUploadCache

java.lang.Object
  extended by org.apache.jackrabbit.core.data.AsyncUploadCache

public class AsyncUploadCache
extends Object

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, AsyncUploadCacheResult) 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
AsyncUploadCache()
           
 
Method Summary
 AsyncUploadCacheResult add(String fileName)
          This methods checks if file can be added to asyncUploadMap.
 void delete(String fileName)
          This methods deletes asynchronous upload for @param fileName if there exists asynchronous upload for @param fileName.
 Set<String> deleteOlderThan(long min)
          Delete in progress asynchronous uploads which are older than @param min.
 Set<String> getAll()
          This methods returns the in progress asynchronous uploads which are not marked for delete.
 long getLastModified(String fileName)
          Returns lastModified from asyncUploadMap if found else returns 0.
 boolean hasEntry(String fileName, boolean touch)
          This methos checks if asynchronous upload is in progress for @param fileName.
 void init(String homeDir, String path, int asyncUploadLimit)
           
 AsyncUploadCacheResult remove(String fileName)
          This methods removes file (if found) from asyncUploadMap.
 void reset()
          Reset the AsyncUploadCache to empty asyncUploadMap and toBeDeleted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncUploadCache

public AsyncUploadCache()
Method Detail

add

public AsyncUploadCacheResult add(String fileName)
                           throws IOException
This methods checks if file can be added to asyncUploadMap. If yes it adds to asyncUploadMap and serializeAsyncUploadMap() the asyncUploadMap to disk.

Returns:
AsyncUploadCacheResult if successfully added to asynchronous uploads it sets AsyncUploadCacheResult.setAsyncUpload(boolean) to true else sets to false.
Throws:
IOException

remove

public AsyncUploadCacheResult remove(String fileName)
                              throws IOException
This methods removes file (if found) from asyncUploadMap. If file is found, it immediately serializes the asyncUploadMap to disk. This method sets AsyncUploadCacheResult.setRequiresDelete(boolean) to true, if asynchronous upload found to be in toBeDeleted set i.e. marked for delete.

Throws:
IOException

getAll

public Set<String> getAll()
This methods returns the in progress asynchronous uploads which are not marked for delete.


hasEntry

public boolean hasEntry(String fileName,
                        boolean touch)
                 throws 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:
IOException

getLastModified

public long getLastModified(String fileName)
Returns lastModified from asyncUploadMap if found else returns 0.


delete

public void delete(String fileName)
            throws IOException
This methods deletes asynchronous upload for @param fileName if there exists asynchronous upload for @param fileName.

Throws:
IOException

deleteOlderThan

public Set<String> deleteOlderThan(long min)
                            throws IOException
Delete in progress asynchronous uploads which are older than @param min. This method leverage lastModified stored in asyncUploadMap

Throws:
IOException

init

public void init(String homeDir,
                 String path,
                 int asyncUploadLimit)
          throws IOException,
                 ClassNotFoundException
Parameters:
homeDir - home directory of repository.
path - path of the LocalCache
asyncUploadLimit - the maximum number of asynchronous uploads
Throws:
IOException
ClassNotFoundException

reset

public void reset()
           throws IOException
Reset the AsyncUploadCache to empty asyncUploadMap and toBeDeleted

Throws:
IOException


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.