|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.archive.arcrepositoryadmin.ReplicaCacheDatabase
public final class ReplicaCacheDatabase
Method for storing the bitpreservation cache in a database. This method uses the 'admin.data' file for retrieving the upload status. TODO this file is extremely large (more than 2000 lines) and should be shortened.
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
log
The log. |
Method Summary | |
---|---|
void |
addChecksumInformation(java.util.List<java.lang.String> checksumOutput,
Replica replica)
Given the output of a checksum job, add the results to the database. |
void |
addFileListInformation(java.util.List<java.lang.String> filelist,
Replica replica)
Method for adding the results from a list of filenames on a replica. |
void |
changeStateOfReplicafileinfo(java.lang.String filename,
Replica replica,
ReplicaStoreState state)
Method for inserting an entry into the database about a file upload has begun for a specific replica. |
void |
changeStateOfReplicafileinfo(java.lang.String filename,
java.lang.String checksum,
Replica replica,
ReplicaStoreState state)
Method for inserting an entry into the database about a file upload has begun for a specific replica. |
void |
cleanup()
Method for cleaning up. |
boolean |
existsFileInDB(java.lang.String filename)
Checks whether a file is already in the file table in the database. |
Replica |
getBitarchiveWithGoodFile(java.lang.String filename)
Method for finding a replica with a valid version of a file. |
Replica |
getBitarchiveWithGoodFile(java.lang.String filename,
Replica badReplica)
Method for finding a replica with a valid version of a file. |
java.lang.String |
getChecksum(java.lang.String filename)
Method for retrieving the checksum for a specific file. |
java.sql.Date |
getDateOfLastMissingFilesUpdate(Replica replica)
Get the date for the last file list job. |
java.sql.Date |
getDateOfLastWrongFilesUpdate(Replica replica)
Method for retrieving the date for the last update for corrupted files. |
static ReplicaCacheDatabase |
getInstance()
Method for retrieving the current instance of this class. |
java.lang.Iterable<java.lang.String> |
getMissingFilesInLastUpdate(Replica replica)
Method for retrieving the list of the names of the files which was missing for the replica in the last filelist update. |
long |
getNumberOfFiles(Replica replica)
Method for retrieving the number of files within a replica. |
long |
getNumberOfMissingFilesInLastUpdate(Replica replica)
Method for retrieving the number of files missing from a specific replica. |
long |
getNumberOfWrongFilesInLastUpdate(Replica replica)
Method for retrieving the amount of files with a incorrect checksum within a replica. |
ReplicaFileInfo |
getReplicaFileInfo(java.lang.String filename,
Replica replica)
Method for retrieving the entry in the replicafileinfo table for a given file and replica. |
ReplicaStoreState |
getReplicaStoreState(java.lang.String filename,
java.lang.String replicaId)
Retrieves the ReplicaStoreState for the entry in the replicafileinfo table, which refers to the given file and replica. |
java.lang.Iterable<java.lang.String> |
getWrongFilesInLastUpdate(Replica replica)
Method for retrieving the list of the files in the replica which have a incorrect checksum. |
protected void |
initialiseDB()
Method for initialising the database. |
boolean |
insertAdminEntry(java.lang.String line)
Method for inserting a line of Admin.Data into the database. |
void |
insertNewFileForUpload(java.lang.String filename,
java.lang.String checksum)
Creates a new entry for the filename for each replica, and give it the given checksum and set the upload_status = UNKNOWN_UPLOAD_STATUS. |
boolean |
isEmpty()
Method for telling whether the database is empty. |
java.util.Collection<java.lang.String> |
retrieveAllFilenames()
Retrieves the names of all the files in the file table of the database. |
java.lang.String |
retrieveAsText()
Method to print all the tables in the database. |
FileListStatus |
retrieveFileListStatus(java.lang.String filename,
Replica replica)
Method for retrieving the filelist_status for a replicafileinfo entry. |
java.util.Collection<java.lang.String> |
retrieveFilenamesForReplicaEntries(java.lang.String replicaId,
ReplicaStoreState state)
Retrieves the names of all the files in the given replica which has the specified UploadStatus. |
void |
setAdminDate(java.sql.Date date)
Method for setting a specific value for the filelistdate and the checksumlistdate for all the replicas. |
void |
setReplicaStoreState(java.lang.String filename,
java.lang.String replicaId,
ReplicaStoreState state)
Sets the ReplicaStoreState for the entry in the replicafileinfo table. |
void |
updateChecksumInformationForFileOnReplica(java.lang.String filename,
java.lang.String checksum,
Replica replica)
Method for updating a specific entry in the replicafileinfo table. |
void |
updateChecksumStatus()
This method is used to update the status for the checksums for all replicafileinfo entries. |
void |
updateChecksumStatus(java.lang.String filename)
Method for updating the status for a specific file for all the replicas. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static org.apache.commons.logging.Log log
Method Detail |
---|
public static ReplicaCacheDatabase getInstance()
protected void initialiseDB()
public ReplicaFileInfo getReplicaFileInfo(java.lang.String filename, Replica replica) throws ArgumentNotValid
getReplicaFileInfo
in interface BitPreservationDAO
filename
- The name of the file for the entry.replica
- The replica of the entry.
ArgumentNotValid
- If the filename is either null or empty, or if
the replica is null.public java.lang.String getChecksum(java.lang.String filename) throws ArgumentNotValid
filename
- The name of the file, whose checksum are to be found.
ArgumentNotValid
- If teh filename is either null or the empty
string.public java.util.Collection<java.lang.String> retrieveAllFilenames()
public ReplicaStoreState getReplicaStoreState(java.lang.String filename, java.lang.String replicaId) throws ArgumentNotValid
filename
- The name of the file in the filetable.replicaId
- The id of the replica.
ArgumentNotValid
- If the replicaId or the filename are eihter
null or the empty string.public void setReplicaStoreState(java.lang.String filename, java.lang.String replicaId, ReplicaStoreState state) throws ArgumentNotValid
filename
- The name of the file in the filetable.replicaId
- The id of the replica.state
- The ReplicaStoreState for the specified entry.
ArgumentNotValid
- If the replicaId or the filename are eihter
null or the empty string. Or if the ReplicaStoreState is null.public void insertNewFileForUpload(java.lang.String filename, java.lang.String checksum) throws ArgumentNotValid, IllegalState
filename
- The name of the file.checksum
- The checksum of the file.
ArgumentNotValid
- If the filename or the checksum is either null
or the empty string.
IllegalState
- If the file exists with another checksum on one of
the replicas. Or if the file has already been completely uploaded to
one of the replicas.public void changeStateOfReplicafileinfo(java.lang.String filename, Replica replica, ReplicaStoreState state) throws ArgumentNotValid
filename
- The name of the file.replica
- The replica for the replicafileinfo.state
- The new ReplicaStoreState for the entry.
ArgumentNotValid
- If the filename is either null or the empty
string. Or if the replica or the status is null.public void changeStateOfReplicafileinfo(java.lang.String filename, java.lang.String checksum, Replica replica, ReplicaStoreState state) throws ArgumentNotValid, IllegalState
filename
- The name of the file.checksum
- The new checksum for the entry.replica
- The replica for the replicafileinfo.state
- The new ReplicaStoreState for the entry.
ArgumentNotValid
- If the filename or the checksum is either null
or the empty string. Or if the replica or the status is null.
IllegalState
- If an sql exception is thrown.public java.util.Collection<java.lang.String> retrieveFilenamesForReplicaEntries(java.lang.String replicaId, ReplicaStoreState state) throws ArgumentNotValid
replicaId
- The id of the replica which contain the files.state
- The ReplicaStoreState for the wanted files.
ArgumentNotValid
- If the UploadStatus is null or if the replicaId
is either null or the empty string.public boolean existsFileInDB(java.lang.String filename) throws IllegalState
filename
- The name of the file in the database.
IllegalState
- If more than one entry with the given filename was
found.public FileListStatus retrieveFileListStatus(java.lang.String filename, Replica replica) throws ArgumentNotValid
filename
- The name of the file.replica
- The replica where the file should be.
ArgumentNotValid
- If the replica is null or the filename is
either null or the empty string.public void updateChecksumStatus()
updateChecksumStatus
in interface BitPreservationDAO
public void updateChecksumStatus(java.lang.String filename) throws ArgumentNotValid
updateChecksumStatus
in interface BitPreservationDAO
filename
- The name of the file to update the status for.
ArgumentNotValid
- If the filename is either null or the empty
string.public void addChecksumInformation(java.util.List<java.lang.String> checksumOutput, Replica replica)
addChecksumInformation
in interface BitPreservationDAO
checksumOutput
- The output of a checksum job.replica
- The replica this checksum job is for.public void addFileListInformation(java.util.List<java.lang.String> filelist, Replica replica) throws ArgumentNotValid, UnknownID
addFileListInformation
in interface BitPreservationDAO
filelist
- The list of filenames either parsed from a FilelistJob
or the result from a GetAllFilenamesMessage.replica
- The replica, which the FilelistBatchjob has run upon.
ArgumentNotValid
- If the filelist or the replica is null.
UnknownID
- If the replica does not already exist in the database.public java.sql.Date getDateOfLastMissingFilesUpdate(Replica replica) throws ArgumentNotValid, java.lang.IllegalArgumentException
getDateOfLastMissingFilesUpdate
in interface BitPreservationDAO
replica
- The replica to get the date for.
ArgumentNotValid
- If the replica is null.
java.lang.IllegalArgumentException
- If the Date of the Timestamp cannot be
instanciated.public java.sql.Date getDateOfLastWrongFilesUpdate(Replica replica) throws ArgumentNotValid, java.lang.IllegalArgumentException
getDateOfLastWrongFilesUpdate
in interface BitPreservationDAO
replica
- The replica to find the date for the latest update for
corruption of files.
ArgumentNotValid
- If the replica is null.
java.lang.IllegalArgumentException
- If the Date of the Timestamp cannot be
instanciated.public long getNumberOfMissingFilesInLastUpdate(Replica replica) throws ArgumentNotValid
getNumberOfMissingFilesInLastUpdate
in interface BitPreservationDAO
replica
- The replica to find the number of missing files for.
ArgumentNotValid
- If the replica is null.public java.lang.Iterable<java.lang.String> getMissingFilesInLastUpdate(Replica replica) throws ArgumentNotValid
getMissingFilesInLastUpdate
in interface BitPreservationDAO
replica
- The replica to find the list of missing files for.
ArgumentNotValid
- If the replica is null.public long getNumberOfWrongFilesInLastUpdate(Replica replica) throws ArgumentNotValid
getNumberOfWrongFilesInLastUpdate
in interface BitPreservationDAO
replica
- The replica to find the number of corrupted files for.
ArgumentNotValid
- If the replica is null.public java.lang.Iterable<java.lang.String> getWrongFilesInLastUpdate(Replica replica) throws ArgumentNotValid
getWrongFilesInLastUpdate
in interface BitPreservationDAO
replica
- The replica to find the list of corrupted files for.
ArgumentNotValid
- If the replica is null.public long getNumberOfFiles(Replica replica) throws ArgumentNotValid
getNumberOfFiles
in interface BitPreservationDAO
replica
- The replica to count the number of files for.
ArgumentNotValid
- If the replica is null.public Replica getBitarchiveWithGoodFile(java.lang.String filename) throws ArgumentNotValid
getBitarchiveWithGoodFile
in interface BitPreservationDAO
filename
- The name of the file which needs to have a valid version
in a bitarchive.
ArgumentNotValid
- If the filename is null or the empty string.public Replica getBitarchiveWithGoodFile(java.lang.String filename, Replica badReplica) throws ArgumentNotValid
getBitarchiveWithGoodFile
in interface BitPreservationDAO
filename
- The name of the file which needs to have a valid version
in a bitarchive.badReplica
- The Replica which has a bad copy of the given file
ArgumentNotValid
- If the replica is null or the filename is either
null or the empty string.public void updateChecksumInformationForFileOnReplica(java.lang.String filename, java.lang.String checksum, Replica replica) throws ArgumentNotValid
updateChecksumInformationForFileOnReplica
in interface BitPreservationDAO
filename
- Name of the file.checksum
- The checksum of the file. Is allowed to be null, if no
file is found.replica
- The replica where the file exists.
ArgumentNotValid
- If the filename is null or the empty string, or
if the replica is null.public boolean insertAdminEntry(java.lang.String line) throws ArgumentNotValid
line
- The line to insert into the database.
ArgumentNotValid
- If the line is null. If it is empty, then it is
logged.public void setAdminDate(java.sql.Date date) throws ArgumentNotValid
date
- The new date for the checksumlist and filelist for all the
replicas.
ArgumentNotValid
- If the date is null.public boolean isEmpty()
public java.lang.String retrieveAsText()
public void cleanup()
cleanup
in interface BitPreservationDAO
cleanup
in interface CleanupIF
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |