Class 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
    • Field Detail

      • storeDir

        protected String storeDir
    • Constructor Detail

      • LocalObjectStore

        public LocalObjectStore()
    • Method Detail

      • fetchObject

        public long fetchObject​(String group,
                                String id,
                                File file)
                         throws IOException
        Description copied from interface: ObjectStore
        Fetches a copy of the object with passed ID, and places it in passed file.
        Specified by:
        fetchObject in interface ObjectStore
        Parameters:
        group - Group
        id - ID
        file - 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: ObjectStore
        Returns whether an object with the passed id exists in the store.
        Specified by:
        objectExists in interface ObjectStore
        Parameters:
        group - Group
        id - 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: ObjectStore
        Removes the passed object from the store.
        Specified by:
        removeObject in interface ObjectStore
        Parameters:
        group - Group
        id - 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: ObjectStore
        Transfers a copy of this file to the object store
        Specified by:
        transferObject in interface ObjectStore
        Parameters:
        group - Group
        file - 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: ObjectStore
        Obtains attributes of the representation of the object with passed ID.
        Specified by:
        objectAttribute in interface ObjectStore
        Parameters:
        group - Group
        id - ID
        attrName - - 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: ObjectStore
        Moves the passed object from one storage group to another.
        Specified by:
        moveObject in interface ObjectStore
        Parameters:
        srcGroup - source group
        destGroup - destination group
        id - 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