Class DatabasePreservationState
- java.lang.Object
-
- dk.netarkivet.archive.arcrepository.bitpreservation.DatabasePreservationState
-
- All Implemented Interfaces:
PreservationState
public class DatabasePreservationState extends Object implements PreservationState
This class contains the preservation data based on the database data of a given filename. Contains the ReplicaFileInfos corresponding to the file.
-
-
Constructor Summary
Constructors Constructor Description DatabasePreservationState(String fileName, List<ReplicaFileInfo> rfis)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
fileIsMissing(Replica replica)
Check if the file is missing from a replica.String
getAdminChecksum()
Get the MD5 checksum stored in the admin data.String
getAdminReplicaState(Replica replica)
Get the status of the file in a replica, according to the admin data.String
getFilename()
Get the filename, this FilePreservationState is about.Replica
getReferenceBitarchive()
Returns a reference to a replica that contains a version of the file with the correct checksum.String
getReferenceCheckSum()
THIS IS VOTING! Retrieve checksum that the majority of checksum references replicas agree upon.List<String>
getReplicaChecksum(Replica replica)
Get the checksum of this file in a specific replica.String
getUniqueChecksum(Replica replica)
Get a checksum that the whole replica agrees upon, or else "".boolean
isAdminCheckSumOk()
Returns true if the checksum reported by admin data is equal to the majority checksum.boolean
isAdminDataOk()
INHERITED DUMMY FUNCTION!String
toString()
Returns a human-readable representation of this object.
-
-
-
Constructor Detail
-
DatabasePreservationState
public DatabasePreservationState(String fileName, List<ReplicaFileInfo> rfis) throws ArgumentNotValid
Constructor.- Parameters:
fileName
- The name of the file.rfis
- A list of the ReplicaFileInfo entries in the database for the given file.- Throws:
ArgumentNotValid
- If the filename is null or the empty string, or if the list of ReplicaFileInfos are null or empty.
-
-
Method Detail
-
getReplicaChecksum
public List<String> getReplicaChecksum(Replica replica) throws ArgumentNotValid
Get the checksum of this file in a specific replica.- Specified by:
getReplicaChecksum
in interfacePreservationState
- Parameters:
replica
- The replica to get the checksum from.- Returns:
- A list of the checksums for the file within the replica (only more than one if there is duplicates in a bitarchive replica). An empty list is returned if no file is present or if an error occurred.
- Throws:
ArgumentNotValid
- If the replica is null.
-
getAdminChecksum
public String getAdminChecksum()
Get the MD5 checksum stored in the admin data. Inherited dummy function. No admin data for database instance, thus no admin data checksum.- Specified by:
getAdminChecksum
in interfacePreservationState
- Returns:
- Checksum value as found in the admin data given at creation.
-
getAdminReplicaState
public String getAdminReplicaState(Replica replica) throws ArgumentNotValid
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 interfacePreservationState
- Parameters:
replica
- The replica to get status for- Returns:
- Status that the admin data knows for this file in the replica.
- Throws:
ArgumentNotValid
- If the replica is null.
-
isAdminDataOk
public boolean isAdminDataOk()
INHERITED DUMMY FUNCTION!- Specified by:
isAdminDataOk
in interfacePreservationState
- Returns:
- true, since a non-existing admin.data is OK for the database instance.
-
getReferenceBitarchive
public Replica getReferenceBitarchive()
Returns a reference to a 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 replica and admin data agree upon.
If no replica exists with a correct version of the file null is returned.
- Specified by:
getReferenceBitarchive
in interfacePreservationState
- Returns:
- the name of the reference replica or null if no reference exists.
-
getUniqueChecksum
public String getUniqueChecksum(Replica replica) throws ArgumentNotValid
Get a checksum that the whole replica agrees upon, or else "".- Specified by:
getUniqueChecksum
in interfacePreservationState
- Parameters:
replica
- 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 "".
- Throws:
ArgumentNotValid
- If the replica is null.
-
fileIsMissing
public boolean fileIsMissing(Replica replica) throws ArgumentNotValid
Check if the file is missing from a replica.- Specified by:
fileIsMissing
in interfacePreservationState
- Parameters:
replica
- the replica to check- Returns:
- true if the file is missing from the replica
- Throws:
ArgumentNotValid
- If the replica is null.
-
getReferenceCheckSum
public String getReferenceCheckSum()
THIS IS VOTING! Retrieve checksum that the majority of checksum references replicas agree upon.TODO Voting is already done by the DatabasedActiveBitPreservation. Thus replace with finding an entry with checksum-status = OK.
- Specified by:
getReferenceCheckSum
in interfacePreservationState
- 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 interfacePreservationState
- 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 interfacePreservationState
- Overrides:
toString
in classObject
- 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 interfacePreservationState
- Returns:
- the filename
-
-