public final class ReplicaCacheHelpers extends Object
ReplicaCacheDatabase
.Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
log
The log.
|
Modifier and Type | Method and Description |
---|---|
protected static long |
addFileInformation(String file,
Replica replica,
Connection con)
Add information about one file in a given replica.
|
protected static void |
createReplicaFileInfoEntriesInDB(long fileId,
Connection con)
When a new file is inserted into the database, each replica gets a new entry in the replicafileinfo table for
this file.
|
protected static boolean |
existsReplicaFileInfoInDB(long fileid,
String replicaID,
Connection con)
Method for checking whether a replicafileinfo is in the database.
|
protected static boolean |
existsReplicaInDB(Replica rep,
Connection con)
Method for testing whether a replica already is within the database.
|
protected static void |
fileChecksumVote(long fileId,
Connection con)
The method for voting about the checksum of a file.
|
protected static ReplicaFileInfo |
getReplicaFileInfo(long replicaFileInfoGuid,
Connection con)
Method for retrieving ReplicaFileInfo entry in the database.
|
protected static long |
insertFileIntoDB(String filename,
Connection connection)
Method to create a new entry in the file table in the database.
|
protected static void |
insertReplicaIntoDB(Replica rep,
Connection con)
Method for inserting a Replica into the replica table.
|
static long |
processChecksumline(String filename,
String checksum,
Replica replica,
Connection con)
Process checksum information about one file in a given replica.
|
protected static String |
retrieveChecksumForReplicaFileInfoEntry(long fileGuid,
String repId,
Connection con)
Retrieves the checksum for a specific entry in the replicafileinfo table identified by the file guid and the
replica id.
|
protected static ChecksumStatus |
retrieveChecksumStatusForReplicaFileInfoEntry(long fileGuid,
String repId,
Connection con)
Retrieves the checksum status for a specific entry in the replicafileinfo table identified by the file guid and
the replica id.
|
protected static int |
retrieveFileListStatusFromReplicaFileInfo(String filename,
String replicaId,
Connection con)
Method for retrieving the filelist_status for the entry in the replicafileinfo table associated with the given
filename for the replica identified with a given id.
|
protected static String |
retrieveFilenameForFileId(long fileId,
Connection con)
Method for retrieving the filename from the entry in the file table which has the fileId as file_id.
|
protected static long |
retrieveGuidForFilenameOnReplica(String filename,
String replicaId,
Connection con)
Retrieve the guid stored for a filename on a given replica.
|
protected static long |
retrieveIdForFile(String filename,
Connection con)
Retrieves the file_id for the corresponding filename.
|
protected static List<String> |
retrieveIdsFromFileTable(Connection con)
Method for retrieving all the file IDs within the database.
|
protected static List<String> |
retrieveIdsFromReplicaFileInfoTable(Connection con)
Method for retrieving all the ReplicaFileInfo GUIDs within the database.
|
protected static List<String> |
retrieveIdsFromReplicaTable(Connection con)
Method for retrieving the replica IDs within the database.
|
protected static long |
retrieveReplicaFileInfoGuid(long fileId,
String replicaId,
Connection con)
Method for retrieving the replicafileinfo_guid for a specific instance defined from the fileId and the replicaId.
|
protected static Set<Long> |
retrieveReplicaFileInfoGuidsForReplica(String replicaId,
Connection con)
Method for retrieving the list of all the replicafileinfo_guids for a specific replica.
|
protected static List<ReplicaFileInfo> |
retrieveReplicaFileInfosWithChecksum(List<Long> rfiGuids,
Connection con)
Method for retrieving the data for the wanted entries in the replicafileinfo table.
|
protected static List<String> |
retrieveReplicaIdsWithOKChecksumStatus(String filename,
Connection con)
Method for retrieving the list of replica, where the file with the given name has the checksum_status 'OK'.
|
protected static ReplicaType |
retrieveReplicaType(String replicaId,
Connection con)
Method for retrieving the replica type for a specific replica.
|
protected static ReplicaStoreState |
retrieveUploadStatus(long fileGuid,
String repId,
Connection con)
Retrieves the UploadStatus for a specific entry in the replicafileinfo table identified by the file guid and the
replica id.
|
protected static void |
setChecksumlistDateForReplica(Replica rep,
Date date,
Connection con)
Method for setting the checksum_updated field for a given replica in the replica table to a specified value.
|
protected static void |
setFilelistDateForReplica(Replica rep,
Date date,
Connection con)
Method for setting the filelist_updated field for a given replica in the replica table to a specified value.
|
protected static void |
updateChecksumDateForReplica(Replica rep,
Connection con)
Method for updating the checksum_updated field for a given replica in the replica table.
|
protected static void |
updateFilelistDateForReplica(Replica rep,
Connection connection)
Method for updating the filelist_updated field for a given replica in the replica table.
|
protected static void |
updateReplicaFileInfo(long replicafileinfoGuid,
String checksum,
Date date,
ReplicaStoreState state,
Connection con)
Method for updating an entry in the replicafileinfo table.
|
protected static void |
updateReplicaFileInfo(long replicafileinfoGuid,
String checksum,
ReplicaStoreState state,
Connection con)
Method for updating an entry in the replicafileinfo table.
|
protected static void |
updateReplicaFileInfoChecksum(long replicafileinfoId,
String checksum,
Connection con)
This is used for updating a replicafileinfo instance based on the results of a checksumjob.
|
protected static void |
updateReplicaFileInfoChecksumCorrupt(long replicafileinfoId,
Connection con)
Method for updating the checksum status of a replicafileinfo instance.
|
protected static void |
updateReplicaFileInfoChecksumOk(long replicafileinfoId,
Connection con)
Method for updating the checksum status of a replicafileinfo instance.
|
protected static void |
updateReplicaFileInfoChecksumUnknown(long replicafileinfoId,
Connection con)
Method for updating the checksum status of a replicafileinfo instance.
|
protected static void |
updateReplicaFileInfoFilelist(long replicafileinfoId,
Connection con)
Method for updating the filelist of a replicafileinfo instance.
|
protected static void |
updateReplicaFileInfoMissingFromFilelist(long replicafileinfoId,
Connection con)
Method for updating the filelist of a replicafileinfo instance.
|
protected static String |
vote(List<String> checksums)
Method for finding the checksum which is present most times in the list.
|
protected static org.slf4j.Logger log
protected static boolean existsReplicaFileInfoInDB(long fileid, String replicaID, Connection con) throws IllegalState
fileid
- The id of the file.replicaID
- The id of the replica.con
- An open connection to the archive databaseIllegalState
- If more than one copy of the replicafileinfo is placed in the database.protected static void insertReplicaIntoDB(Replica rep, Connection con) throws IOFailure
rep
- The Replica to insert into the replica table.con
- An open connection to the archive databaseIOFailure
- If a SQLException is caught.protected static long insertFileIntoDB(String filename, Connection connection) throws IllegalState
filename
- The filename for the new entry in the file table.connection
- An open connection to the archive databaseIllegalState
- If the file cannot be inserted into the database.protected static void createReplicaFileInfoEntriesInDB(long fileId, Connection con) throws IllegalState
The replicafileinfo_guid is automatically created by the database, and the dates are set to null.
fileId
- The id for the file.con
- An open connection to the archive databaseIllegalState
- If the file could not be entered into the database.protected static List<String> retrieveIdsFromReplicaTable(Connection con)
con
- An open connection to the archive databaseprotected static List<String> retrieveIdsFromFileTable(Connection con)
con
- An open connection to the archive databaseprotected static List<String> retrieveIdsFromReplicaFileInfoTable(Connection con)
con
- An open connection to the archive databaseprotected static long retrieveIdForFile(String filename, Connection con)
filename
- The entry in the filename list where the corresponding file_id should be found.con
- An open connection to the archive databaseprotected static long retrieveReplicaFileInfoGuid(long fileId, String replicaId, Connection con)
fileId
- The identifier for the file.replicaId
- The identifier for the replica.con
- An open connection to the archive databaseprotected static Set<Long> retrieveReplicaFileInfoGuidsForReplica(String replicaId, Connection con)
replicaId
- The id for the replica to contain the files.con
- An open connection to the archiveDatabase.protected static ReplicaType retrieveReplicaType(String replicaId, Connection con)
replicaId
- The id of the replica.con
- An open connection to the archiveDatabase.protected static List<String> retrieveReplicaIdsWithOKChecksumStatus(String filename, Connection con)
filename
- The name of the file.con
- An open connection to the archive databaseprotected static String retrieveFilenameForFileId(long fileId, Connection con)
fileId
- The file_id of the entry in the file table for which to retrieve the filename.con
- An open connection to the archive databaseprotected static int retrieveFileListStatusFromReplicaFileInfo(String filename, String replicaId, Connection con)
filename
- the filename of the file for which you want a status.replicaId
- The identifier of the replicacon
- An open connection to the archive databaseprotected static void updateReplicaFileInfoChecksum(long replicafileinfoId, String checksum, Connection con)
replicafileinfoId
- The unique id for the replicafileinfo.checksum
- The new checksum for the entry.con
- An open connection to the archive databaseprotected static void updateReplicaFileInfoFilelist(long replicafileinfoId, Connection con)
replicafileinfoId
- The id of the replicafileinfo.con
- An open connection to the archive databaseprotected static void updateReplicaFileInfoMissingFromFilelist(long replicafileinfoId, Connection con)
The replicafileinfo is in the filelist.
replicafileinfoId
- The id of the replicafileinfo.con
- An open connection to the archive databaseprotected static void updateReplicaFileInfoChecksumCorrupt(long replicafileinfoId, Connection con)
The replicafileinfo is in the filelist.
replicafileinfoId
- The id of the replicafileinfo.con
- An open connection to the archive databaseprotected static long retrieveGuidForFilenameOnReplica(String filename, String replicaId, Connection con)
filename
- a given filenamereplicaId
- An identifier for a replica.con
- An open connection to the archive databaseprotected static void updateReplicaFileInfoChecksumUnknown(long replicafileinfoId, Connection con)
The replicafileinfo is in the filelist.
replicafileinfoId
- The id of the replicafileinfo.con
- An open connection to the archive databaseprotected static void updateReplicaFileInfoChecksumOk(long replicafileinfoId, Connection con)
replicafileinfoId
- The id of the replicafileinfo.con
- An open connection to the archive databaseprotected static void updateChecksumDateForReplica(Replica rep, Connection con)
The following fields for the entry in the replica table:
checksum_updated = now.
rep
- The replica which has just been updated.con
- An open connection to the archive databaseprotected static void updateFilelistDateForReplica(Replica rep, Connection connection)
The following fields for the entry in the replica table:
filelist_updated = now.
rep
- The replica which has just been updated.connection
- An open connection to the archive databaseprotected static void setFilelistDateForReplica(Replica rep, Date date, Connection con)
The following fields for the entry in the replica table:
filelist_updated = date.
rep
- The replica which has just been updated.date
- The date for the last filelist update.con
- An open connection to the archive databaseprotected static void setChecksumlistDateForReplica(Replica rep, Date date, Connection con)
The following fields for the entry in the replica table:
checksum_updated = date.
rep
- The replica which has just been updated.date
- The date for the last checksum update.con
- An open connection to the archive databaseprotected static boolean existsReplicaInDB(Replica rep, Connection con)
rep
- The replica to find in the database.con
- An open connection to the archive databaseprotected static ReplicaFileInfo getReplicaFileInfo(long replicaFileInfoGuid, Connection con)
replicaFileInfoGuid
- The guid for the specific replicafileinfo.con
- An open connection to the archive databaseprotected static List<ReplicaFileInfo> retrieveReplicaFileInfosWithChecksum(List<Long> rfiGuids, Connection con)
rfiGuids
- The list of guids for the entries in the replicafileinfo table which is wanted.con
- An open connection to the archive databaseprotected static void updateReplicaFileInfo(long replicafileinfoGuid, String checksum, ReplicaStoreState state, Connection con) throws IOFailure
replicafileinfoGuid
- The guid to update.checksum
- The new checksum for the entry.state
- The state for the upload.con
- An open connection to the archive databaseIOFailure
- If an error occurs in the database connection.protected static void updateReplicaFileInfo(long replicafileinfoGuid, String checksum, Date date, ReplicaStoreState state, Connection con) throws IOFailure
replicafileinfoGuid
- The guid to update.checksum
- The new checksum for the entry.date
- The date for the update.state
- The status for the upload.con
- An open connection to the archive databaseIOFailure
- If an error occurs in the connection to the database.protected static ReplicaStoreState retrieveUploadStatus(long fileGuid, String repId, Connection con)
fileGuid
- The id of the file.repId
- The id of the replica.con
- An open connection to the archive databaseprotected static String retrieveChecksumForReplicaFileInfoEntry(long fileGuid, String repId, Connection con)
fileGuid
- The guid of the file in the file table.repId
- The id of the replica.con
- An open connection to the archive databaseprotected static ChecksumStatus retrieveChecksumStatusForReplicaFileInfoEntry(long fileGuid, String repId, Connection con)
fileGuid
- The guid of the file in the file table.repId
- The id of the replica.con
- An open connection to the archive databaseprotected static String vote(List<String> checksums)
checksums
- The list of checksum to vote about.protected static void fileChecksumVote(long fileId, Connection con)
fileId
- The id for the file to vote about.con
- An open connection to the archive databaseprotected static long addFileInformation(String file, Replica replica, Connection con)
file
- The name of a filereplica
- A replicacon
- An open connection to the ArchiveDatabasepublic static long processChecksumline(String filename, String checksum, Replica replica, Connection con)
filename
- The name of a filechecksum
- The checksum of that file.replica
- A replicacon
- An open connection to the ArchiveDatabaseCopyright © 2005–2015 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.