Class FileBasedActiveBitPreservation
- java.lang.Object
-
- dk.netarkivet.archive.arcrepository.bitpreservation.FileBasedActiveBitPreservation
-
- All Implemented Interfaces:
ActiveBitPreservation
,CleanupIF
@Deprecated public class FileBasedActiveBitPreservation extends Object implements ActiveBitPreservation, CleanupIF
Deprecated.Use the DatabaseBasedActiveBitPreservation instead (define in the setting: settings.archive.admin.class).Class handling integrity check of the arcrepository.This class must run on the same machine as the arcrepository, as it uses the same admin data file (read-only). However, it still talks JMS with the arcrepository.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FileBasedActiveBitPreservation()
Deprecated.Initializes a FileBasedActiveBitPreservation instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addMissingFilesToAdminData(String... filenames)
Deprecated.Reestablish admin data to match bitarchive states for files.void
changeStateForAdminData(String filename)
Deprecated.Reestablish admin data to match replica states for file.void
cleanup()
Deprecated.Used to clean up a class from within a shutdown hook.void
close()
Deprecated.Shut down cleanly.void
findChangedFiles(Replica replica)
Deprecated.This method finds out which files in a given bitarchive are misrepresented in the admin data: Either having the wrong checksum or not being marked as uploaded when it actually is.void
findMissingFiles(Replica replica)
Deprecated.This method takes as input the name of a replica for which we wish to retrieve the list of files, either through a FileListJob or a GetAllFilenamesMessage.Iterable<String>
getChangedFiles(Replica bitarchive)
Deprecated.Get a list of corrupt files in a given bitarchive.Iterable<String>
getChangedFilesForAdminData()
Deprecated.Return a list of files with wrong checksum or status in admin data.Date
getDateForChangedFiles(Replica replica)
Deprecated.Get the date for last time the checksum information was updated for this replica.Date
getDateForMissingFiles(Replica replica)
Deprecated.Get the date for last time the missing files information was updated for this replica.static FileBasedActiveBitPreservation
getInstance()
Deprecated.Get singleton instance.Iterable<String>
getMissingFiles(Replica replica)
Deprecated.Get a list of missing files in a given replica.Iterable<String>
getMissingFilesForAdminData()
Deprecated.Return a list of files present in bitarchive but missing in AdminData.long
getNumberOfChangedFiles(Replica replica)
Deprecated.Get the number of wrong files for a replica.long
getNumberOfFiles(Replica replica)
Deprecated.Return the number of files found in the replica.long
getNumberOfMissingFiles(Replica replica)
Deprecated.Get the number of missing files in a given replica.PreservationState
getPreservationState(String filename)
Deprecated.Get the details of the state of the given file in the bitarchives and admin data.Map<String,PreservationState>
getPreservationStateMap(String... filenames)
Deprecated.Retrieve the preservation status for the files with the given filenames.void
replaceChangedFile(Replica replica, String filename, String credentials, String checksum)
Deprecated.Check that file checksum is indeed different to admin data and reference replica.void
uploadMissingFiles(Replica replica, String... filenames)
Deprecated.Check that the files we want to restore are indeed missing on the replica, and present in admin data and the reference bitarchive.
-
-
-
Method Detail
-
getInstance
public static FileBasedActiveBitPreservation getInstance()
Deprecated.Get singleton instance.- Returns:
- the singleton.
-
getPreservationStateMap
public Map<String,PreservationState> getPreservationStateMap(String... filenames) throws ArgumentNotValid
Deprecated.Retrieve the preservation status for the files with the given filenames. This will ask for a fresh checksum from the bitarchives and admin data.- Specified by:
getPreservationStateMap
in interfaceActiveBitPreservation
- Parameters:
filenames
- List of filenames- Returns:
- a map ([filename]-> [FilePreservationState]) of the preservation status for the given files. The preservationstate is null, if the file named does not exist in admin data.
- Throws:
ArgumentNotValid
- If the list of filenames is null or contains a null.
-
getPreservationState
public PreservationState getPreservationState(String filename)
Deprecated.Get the details of the state of the given file in the bitarchives and admin data.- Specified by:
getPreservationState
in interfaceActiveBitPreservation
- Parameters:
filename
- A given file- Returns:
- the FilePreservationState for the given file. This will be null, if the filename is not found in admin data.
-
getMissingFiles
public Iterable<String> getMissingFiles(Replica replica) throws IllegalState, ArgumentNotValid
Deprecated.Get a list of missing files in a given replica.- Specified by:
getMissingFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- A given replica.- Returns:
- A list of missing files in a given replica.
- Throws:
IllegalState
- if the file with the list cannot be found.ArgumentNotValid
- If the replica is null.
-
findMissingFiles
public void findMissingFiles(Replica replica) throws ArgumentNotValid, PermissionDenied
Deprecated.This method takes as input the name of a replica for which we wish to retrieve the list of files, either through a FileListJob or a GetAllFilenamesMessage. It also reads in the known files in the arcrepository from the AdminData directory specified in the Setting DIRS_ARCREPOSITORY_ADMIN. The two file lists are compared and a subdirectory missingFiles is created with two unsorted files: 'missingba.txt' containing missing files, ie those registered in the admin data, but not found in the replica, and 'missingadmindata.txt' containing extra files, ie. those found in the replica but not in the arcrepository admin data.TODO The second file is never used on the current implementation.
FIXME: It is unclear if the decision if which files are missing isn't better suited to be in getMissingFiles, so this method only runs the batch job.
- Specified by:
findMissingFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- the replica to search for missing files- Throws:
ArgumentNotValid
- If the given directory does not contain a file filelistOutput/sorted.txt, or the argument replica is null.PermissionDenied
- If the output directory cannot be created.
-
getChangedFiles
public Iterable<String> getChangedFiles(Replica bitarchive) throws IllegalState
Deprecated.Get a list of corrupt files in a given bitarchive.- Specified by:
getChangedFiles
in interfaceActiveBitPreservation
- Parameters:
bitarchive
- a bitarchive- Returns:
- a list of wrong files in a given bitarchive.
- Throws:
IllegalState
- if the file with the list cannot be found.
-
findChangedFiles
public void findChangedFiles(Replica replica) throws IOFailure, PermissionDenied, ArgumentNotValid
Deprecated.This method finds out which files in a given bitarchive are misrepresented in the admin data: Either having the wrong checksum or not being marked as uploaded when it actually is.It uses the admindata file from the DIRS_ARCREPOSITORY_ADMIN directory, as well as the files output by a runChecksumJob. The erroneous files are stored in files.
FIXME: It is unclear if the decision if which files are changed isn't better suited to be in getChangedFiles, so this method only runs the batch job.
- Specified by:
findChangedFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- the bitarchive replica the checksumjob came from- Throws:
IOFailure
- On file or network trouble.PermissionDenied
- if the output directory cannot be createdArgumentNotValid
- if argument replica is null
-
getNumberOfFiles
public long getNumberOfFiles(Replica replica) throws ArgumentNotValid
Deprecated.Return the number of files found in the replica. If nothing is known about the replica, -1 is returned.- Specified by:
getNumberOfFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- the bitarchive to check- Returns:
- the number of files found in the bitarchive. If nothing is known about the bitarchive replica, -1 is returned.
- Throws:
ArgumentNotValid
- If the replica is null.
-
getNumberOfMissingFiles
public long getNumberOfMissingFiles(Replica replica) throws ArgumentNotValid
Deprecated.Get the number of missing files in a given replica. If nothing is known about the replica, -1 is returned.- Specified by:
getNumberOfMissingFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- a given replica.- Returns:
- the number of missing files in the given replica. If nothing is known about the replica, -1 is returned.
- Throws:
ArgumentNotValid
- If the replica is null.
-
getNumberOfChangedFiles
public long getNumberOfChangedFiles(Replica replica) throws ArgumentNotValid
Deprecated.Get the number of wrong files for a replica. If nothing is known about the replica, -1 is returned.- Specified by:
getNumberOfChangedFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- a replica.- Returns:
- the number of wrong files for the replica. If nothing is known about the replica, -1 is returned.
- Throws:
ArgumentNotValid
- If the replica is null.
-
getDateForChangedFiles
public Date getDateForChangedFiles(Replica replica) throws ArgumentNotValid
Deprecated.Get the date for last time the checksum information was updated for this replica.- Specified by:
getDateForChangedFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- The replica to check last time for.- Returns:
- The date for last check. Will return 1970-01-01 for never.
- Throws:
ArgumentNotValid
- If the replica is null.
-
getDateForMissingFiles
public Date getDateForMissingFiles(Replica replica) throws ArgumentNotValid
Deprecated.Get the date for last time the missing files information was updated for this replica.- Specified by:
getDateForMissingFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- The replica to check last time for.- Returns:
- The date for last check. Will return 1970-01-01 for never.
- Throws:
ArgumentNotValid
- If the replica is null.
-
uploadMissingFiles
public void uploadMissingFiles(Replica replica, String... filenames) throws IOFailure, IllegalState, ArgumentNotValid
Deprecated.Check that the files we want to restore are indeed missing on the replica, and present in admin data and the reference bitarchive. If so, upload missing files from reference replica to this replica.- Specified by:
uploadMissingFiles
in interfaceActiveBitPreservation
- Parameters:
replica
- The replica to restore files tofilenames
- The names of the files.- Throws:
IllegalState
- If one of the files is unknown (For all known files, there will be an attempt at udpload)IOFailure
- If some file cannot be reestablished. All files will be attempted, though.ArgumentNotValid
- If the replica or the list of filenames are null.
-
replaceChangedFile
public void replaceChangedFile(Replica replica, String filename, String credentials, String checksum) throws ArgumentNotValid, IOFailure, PermissionDenied
Deprecated.Check that file checksum is indeed different to admin data and reference replica. If so, remove missing file and upload it from reference replica to this replica.- Specified by:
replaceChangedFile
in interfaceActiveBitPreservation
- Parameters:
replica
- The replica to restore file tofilename
- The name of the file.credentials
- The credentials used to perform this replace operationchecksum
- The expected checksum.- Throws:
IOFailure
- if the file cannot be reestablishedPermissionDenied
- if the file is not in correct stateArgumentNotValid
- If the filename, the credentials or the checksum either are null or contain the empty string, or if the replica is null.
-
getMissingFilesForAdminData
public Iterable<String> getMissingFilesForAdminData() throws NotImplementedException
Deprecated.Return a list of files present in bitarchive but missing in AdminData.- Specified by:
getMissingFilesForAdminData
in interfaceActiveBitPreservation
- Returns:
- A list of missing files.
- Throws:
NotImplementedException
- Always, since this will not been implemented.
-
getChangedFilesForAdminData
public Iterable<String> getChangedFilesForAdminData() throws NotImplementedException
Deprecated.Return a list of files with wrong checksum or status in admin data.- Specified by:
getChangedFilesForAdminData
in interfaceActiveBitPreservation
- Returns:
- A list of files with wrong checksum or status.
- Throws:
NotImplementedException
- Always, since this will not been implemented.
-
addMissingFilesToAdminData
public void addMissingFilesToAdminData(String... filenames) throws NotImplementedException, ArgumentNotValid
Deprecated.Reestablish admin data to match bitarchive states for files.- Specified by:
addMissingFilesToAdminData
in interfaceActiveBitPreservation
- Parameters:
filenames
- The files to reestablish state for.- Throws:
NotImplementedException
- Always, since this will not been implemented.ArgumentNotValid
- If the list of filenames are null.
-
changeStateForAdminData
public void changeStateForAdminData(String filename) throws PermissionDenied, ArgumentNotValid
Deprecated.Reestablish admin data to match replica states for file.- Specified by:
changeStateForAdminData
in interfaceActiveBitPreservation
- Parameters:
filename
- The file to reestablish state for.- Throws:
PermissionDenied
- if the file is not in correct stateArgumentNotValid
- If the filename is null or empty.
-
close
public void close()
Deprecated.Shut down cleanly.
-
cleanup
public void cleanup()
Deprecated.Description copied from interface:CleanupIF
Used to clean up a class from within a shutdown hook. Must not do any logging. Program defensively, please.- Specified by:
cleanup
in interfaceCleanupIF
- See Also:
CleanupIF.cleanup()
-
-