Class DatabaseBasedActiveBitPreservation

  • All Implemented Interfaces:
    ActiveBitPreservation, CleanupIF

    public final class DatabaseBasedActiveBitPreservation
    extends Object
    implements ActiveBitPreservation, CleanupIF
    The database based active bit preservation. This is the alternative to the FileBasedActiveBitPreservation.

    A database is used to handle the bitpreservation.

    • Method Detail

      • getNumberOfChangedFiles

        public long getNumberOfChangedFiles​(Replica replica)
                                     throws ArgumentNotValid
        The method calculates the number of files which has a wrong checksum for the replica. This simple counts all the entries in the replicafileinfo table for the replica where the filelist_status is set to CORRUPT.
        Specified by:
        getNumberOfChangedFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica for which to count the number of changed files.
        Returns:
        The number of files for the replica where the checksum does not correspond to the checksum of the same file in the other replicas.
        Throws:
        ArgumentNotValid - If the replica is null.
      • getChangedFiles

        public Iterable<String> getChangedFiles​(Replica replica)
                                         throws ArgumentNotValid
        This method retrieves the name of all the files which has a wrong checksum for the replica. It simple returns the filename of all the entries in the replicafileinfo table for the replica where the filelist_status is set to CORRUPT.
        Specified by:
        getChangedFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica for which the changed files should be found.
        Returns:
        The names of files in the replica where the checksum does not correspond to the checksum of the same file in the other replicas.
        Throws:
        ArgumentNotValid - If the replica is null.
      • getNumberOfMissingFiles

        public long getNumberOfMissingFiles​(Replica replica)
                                     throws ArgumentNotValid
        This method calculates the number of files which are not found in the given replica. This simple counts all the entries in the replicafileinfo table for the replica where the filelist_status is set to MISSING.
        Specified by:
        getNumberOfMissingFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica for which to count the number of missing files.
        Returns:
        The number of files which is missing in the replica.
        Throws:
        ArgumentNotValid - If the replica is null.
      • getMissingFiles

        public Iterable<String> getMissingFiles​(Replica replica)
                                         throws ArgumentNotValid
        This method retrieves the name of all the files which are missing for the given replica. It simple returns the filename of all the entries in the replicafileinfo table for the replica where the filelist_status is set to MISSING.
        Specified by:
        getMissingFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica for which the missing files should be found.
        Returns:
        The names of files in the replica which are missing.
        Throws:
        ArgumentNotValid - If the replica is null.
      • getDateForChangedFiles

        public Date getDateForChangedFiles​(Replica replica)
                                    throws ArgumentNotValid
        This method retrieves the date for the latest checksum update was performed for the replica. This means the date for the latest the replica has calculated the checksum of all the files within its archive.

        This method does not call out to the replicas. It only contacts the local database.

        Specified by:
        getDateForChangedFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica for which the date for last checksum update should be retrieved.
        Returns:
        The date for the last time the checksums has been update. If the checksum update has never occurred, then a null is returned.
        Throws:
        ArgumentNotValid - If the replica is null.
      • getDateForMissingFiles

        public Date getDateForMissingFiles​(Replica replica)
                                    throws ArgumentNotValid
        This method retrieves the date for the latest filelist update was performed for the replica. This means the date for the latest the replica has retrieved the list of all the files within the archive.

        This method does not call out to the replicas. It only contacts the local database.

        Specified by:
        getDateForMissingFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica for which the date for last filelist update should be retrieved.
        Returns:
        The date for the last time the filelist has been update. If the filelist update has never occurred, then a null is returned.
        Throws:
        ArgumentNotValid - If the replica is null.
      • findChangedFiles

        public void findChangedFiles​(Replica replica)
                              throws ArgumentNotValid
        The method is used to update the checksum for all the files in a replica. The checksum for the replica is retrieved through GetAllChecksumMessages. This will take a very large amount of time for the bitarchive, but a more limited amount of time for the checksumarchive.

        The corresponding replicafileinfo entries in the database for the retrieved checksum results will be updated. Then a checksum update will be performed to check for corrupted replicafileinfo.

        Each replica can only be updated once at the time.

        Specified by:
        findChangedFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica to find the changed files for.
        Throws:
        ArgumentNotValid - If the replica is null.
      • findMissingFiles

        public void findMissingFiles​(Replica replica)
                              throws ArgumentNotValid
        This method retrieves the filelist for the replica, and then it updates the database with this list of filenames. Each replica can only be updated once at the time.
        Specified by:
        findMissingFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica to find the missing files for.
        Throws:
        ArgumentNotValid - If the replica is null.
      • getNumberOfFiles

        public long getNumberOfFiles​(Replica replica)
                              throws ArgumentNotValid
        This method finds the number of files which are known to be in the archive of a specific replica. This method will not go out to the replica, but only contact the local database. The number of files in the replica is retrieved from the database by counting the amount of files in the replicafileinfo table which belong to the replica and which has the filelist_status set to OK.
        Specified by:
        getNumberOfFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica for which the number of files should be counted.
        Returns:
        The number of files for a specific replica.
        Throws:
        ArgumentNotValid - If the replica is null.
      • replaceChangedFile

        public void replaceChangedFile​(Replica replica,
                                       String filename,
                                       String credentials,
                                       String checksum)
                                throws ArgumentNotValid
        Check that the checksum of the file is indeed different to the value in admin data and reference replica. If so, remove missing file and upload it from reference replica to this replica.
        Specified by:
        replaceChangedFile in interface ActiveBitPreservation
        Parameters:
        replica - The replica to restore file to
        filename - The name of the file
        credentials - The credentials used to perform this replace operation
        checksum - The known bad checksum. Only a file with this bad checksum is attempted repaired.
        Throws:
        ArgumentNotValid - If any of the arguments are not valid.
      • uploadMissingFiles

        public void uploadMissingFiles​(Replica replica,
                                       String... filenames)
                                throws ArgumentNotValid,
                                       IOFailure
        This method is used to upload missing files to a replica. For each file a good version of this file is found, and it is reestablished on the replicas where it is missing.
        Specified by:
        uploadMissingFiles in interface ActiveBitPreservation
        Parameters:
        replica - The replica where the files are missing.
        filenames - The names of the files which are missing in the given replica.
        Throws:
        ArgumentNotValid - If the replica or list of filenames is null, or if the list of filenames is empty.
        IOFailure - If some files could not be established.
      • close

        public void close()
        Method for closing the running instance of this class.
      • cleanup

        public void cleanup()
        Method for cleaning up this instance.
        Specified by:
        cleanup in interface CleanupIF