Package org.dspace.ctask.replicate.store
Class LocalObjectStore
- java.lang.Object
-
- org.dspace.ctask.replicate.store.LocalObjectStore
-
- All Implemented Interfaces:
ObjectStore
- Direct Known Subclasses:
MountableObjectStore
public class LocalObjectStore extends Object implements ObjectStore
LocalObjectStore uses the local file system to manage replicas or other content. As such, it is not intended to provide the level of assurance that a remote, externally managed service can provide. It's primary use is in testing and validating the replication service, not as a production replica store. Note in particular that certain filesystem limits on number of files in a directory may limit its use. It stores replicas as archive files. Also note that for efficiency, this store assumes that File.renameTo will succeed, and renames are preferred to copies when possible. Where this assumption is not valid (e.g. with an NFS-mounted store), use the MountableObjectStore class instead.- Author:
- richardrodgers
-
-
Constructor Summary
Constructors Constructor Description LocalObjectStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longfetchObject(String group, String id, File file)Fetches a copy of the object with passed ID, and places it in passed file.voidinit()Initializes the storage service for use.longmoveObject(String srcGroup, String destGroup, String id)Moves the passed object from one storage group to another.StringobjectAttribute(String group, String id, String attrName)Obtains attributes of the representation of the object with passed ID.booleanobjectExists(String group, String id)Returns whether an object with the passed id exists in the store.longremoveObject(String group, String id)Removes the passed object from the store.longtransferObject(String group, File file)Transfers a copy of this file to the object store
-
-
-
Field Detail
-
storeDir
protected String storeDir
-
-
Method Detail
-
init
public void init() throws IOExceptionDescription copied from interface:ObjectStoreInitializes the storage service for use.- Specified by:
initin interfaceObjectStore- Throws:
IOException- if I/O error
-
fetchObject
public long fetchObject(String group, String id, File file) throws IOException
Description copied from interface:ObjectStoreFetches a copy of the object with passed ID, and places it in passed file.- Specified by:
fetchObjectin interfaceObjectStore- Parameters:
group- Groupid- IDfile- File- Returns:
- number of bytes the replica used
- Throws:
IOException- if I/O error
-
objectExists
public boolean objectExists(String group, String id)
Description copied from interface:ObjectStoreReturns whether an object with the passed id exists in the store.- Specified by:
objectExistsin interfaceObjectStore- Parameters:
group- Groupid- ID- Returns:
- true if a representation of the object named by ID exists
-
removeObject
public long removeObject(String group, String id)
Description copied from interface:ObjectStoreRemoves the passed object from the store.- Specified by:
removeObjectin interfaceObjectStore- Parameters:
group- Groupid- the id of the object to remove- Returns:
- number of bytes the object was using, or 0 if object did not exist.
-
transferObject
public long transferObject(String group, File file) throws IOException
Description copied from interface:ObjectStoreTransfers a copy of this file to the object store- Specified by:
transferObjectin interfaceObjectStore- Parameters:
group- Groupfile- the file to transfer to store- Returns:
- number of bytes transferred to store or 0 if transfer failed.
- Throws:
IOException- if I/O error
-
objectAttribute
public String objectAttribute(String group, String id, String attrName) throws IOException
Description copied from interface:ObjectStoreObtains attributes of the representation of the object with passed ID.- Specified by:
objectAttributein interfaceObjectStore- Parameters:
group- Groupid- IDattrName- - name of the attribute- Returns:
- value of the attribute if it exists, else null
- Throws:
IOException- if I/O error
-
moveObject
public long moveObject(String srcGroup, String destGroup, String id) throws IOException
Description copied from interface:ObjectStoreMoves the passed object from one storage group to another.- Specified by:
moveObjectin interfaceObjectStore- Parameters:
srcGroup- source groupdestGroup- destination groupid- the id of the object to move between groups- Returns:
- number of bytes moved or 0 if move failed.
- Throws:
IOException- if I/O error
-
-