Class FilePreservationState

  • All Implemented Interfaces:
    PreservationState

    public class FilePreservationState
    extends Object
    implements PreservationState
    This class collects the available bit preservation information for a file.
    This information is the following:
    1) admin information for the file for each replica and

    2) the actual upload status
    • Method Detail

      • getReplicaChecksum

        public List<String> getReplicaChecksum​(Replica replica)
        Get the checksum of this file in a specific replica.
        Specified by:
        getReplicaChecksum in interface PreservationState
        Parameters:
        replica - The replica to get the checksum from.
        Returns:
        The file's checksum, if it is present in the replica, or "" if it either is absent or an error occurred.
      • getAdminChecksum

        public String getAdminChecksum()
        Get the MD5 checksum stored in the admin data.
        Specified by:
        getAdminChecksum in interface PreservationState
        Returns:
        Checksum value as found in the admin data given at creation.
      • getAdminReplicaState

        public String getAdminReplicaState​(Replica replica)
        Get the status of the file in a replica, according to the admin data. This returns the status as a string for presentation purposes only.
        Specified by:
        getAdminReplicaState in interface PreservationState
        Parameters:
        replica - The replica to get status for
        Returns:
        Status that the admin data knows for this file in the replica.
      • isAdminDataOk

        public boolean isAdminDataOk()
        Check if the admin data reflect the actual status of the archive.

        Admin State checking: For each replica the admin state is compared to the checksum received from the replica.

        If no checksum is received from the replica the valid admin states are UPLOAD_STARTED and UPLOAD_FAILED. If a checksum is received from the replica the valid admin state is UPLOAD_COMPLETED Admin checksum checking: The admin checksum must match the majority of reported checksums.

        Notice that a valid Admin data record does NOT imply that everything is ok. Specifically a file may be missing from a replica, or the checksum of a file in a replica may be wrong.

        Specified by:
        isAdminDataOk in interface PreservationState
        Returns:
        true, if admin data match the state of the replicas, false otherwise
      • fileIsMissing

        public boolean fileIsMissing​(Replica replica)
        Check if the file is missing from a replica.
        Specified by:
        fileIsMissing in interface PreservationState
        Parameters:
        replica - the replica to check.
        Returns:
        true if the file is missing from the replica.
      • getReferenceBitarchive

        public Replica getReferenceBitarchive()
        Returns a reference to a bitarchive replica that contains a version of the file with the correct checksum.

        The correct checksum is defined as the checksum that the majority of the replicas and admin data agree upon.

        If no bitarchive replica exists with a correct version of the file null is returned.

        Specified by:
        getReferenceBitarchive in interface PreservationState
        Returns:
        the name of the reference replica or null if no reference exists.
      • getUniqueChecksum

        public String getUniqueChecksum​(Replica r)
        Get a checksum that the whole replica agrees upon, or else "".
        Specified by:
        getUniqueChecksum in interface PreservationState
        Parameters:
        r - A replica to get checksum for this file from
        Returns:
        The checksum for this file in the replica, if all machines that have that file agree, otherwise "". If no checksums are found, also returns "".
      • getReferenceCheckSum

        public String getReferenceCheckSum()
        Retrieve checksum that the majority of checksum references (replicas+admin) agree upon.
        Specified by:
        getReferenceCheckSum in interface PreservationState
        Returns:
        the reference checksum or "" if no majority exists
      • isAdminCheckSumOk

        public boolean isAdminCheckSumOk()
        Returns true if the checksum reported by admin data is equal to the majority checksum. If no majority checksum exists true is also returned. When this method returns false it is possible to correct the admin checksum using the majority checksum - when true is returned no better checksum exists for admin data.
        Specified by:
        isAdminCheckSumOk in interface PreservationState
        Returns:
        true, if the checksum reported by admin data is equal to the majority checksum
      • toString

        public String toString()
        Returns a human-readable representation of this object. Do not depend on this format for anything automated, as it may change at any time.
        Specified by:
        toString in interface PreservationState
        Overrides:
        toString in class Object
        Returns:
        Description of this object.
      • getFilename

        public String getFilename()
        Get the filename, this FilePreservationState is about. Needed to get at the filename given to constructor, and allow for a better datastructure.
        Specified by:
        getFilename in interface PreservationState
        Returns:
        the filename