Class ChecksumFileServer
- java.lang.Object
-
- dk.netarkivet.archive.distribute.ArchiveMessageHandler
-
- dk.netarkivet.archive.checksum.distribute.ChecksumArchiveServer
-
- dk.netarkivet.archive.checksum.distribute.ChecksumFileServer
-
- All Implemented Interfaces:
ArchiveMessageVisitor
,CleanupIF
,javax.jms.MessageListener
public class ChecksumFileServer extends ChecksumArchiveServer
The server for the ChecksumFileApplication. Used for communication between the ArcRepository and the checksum archive.
-
-
Field Summary
Fields Modifier and Type Field Description static String
APPLICATION_ID_SEPARATOR
The character to separate the applicationInstanceId and the IP address.protected ChecksumArchive
cs
The archive which contain the actual data.protected static ChecksumFileServer
instance
The instance of this server.-
Fields inherited from class dk.netarkivet.archive.checksum.distribute.ChecksumArchiveServer
checksumAppId, jmsCon, theCR
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Method for cleaning up, when closing this instance down.void
close()
Method for closing the instance.protected String
createAppId()
Method for creating the identification for this application.String
getAppId()
Method for retrieving the identification of this application.static ChecksumFileServer
getInstance()
Returns the unique instance of this class.void
visit(UploadMessage msg)
The method for uploading arc files.void
visit(CorrectMessage msg)
Method for correcting an entry in the archive.void
visit(GetAllChecksumsMessage msg)
Method for retrieving a map containing all the checksums and their corresponding filenames within the archive.void
visit(GetAllFilenamesMessage msg)
Method for retrieving all the filenames within the archive.void
visit(GetChecksumMessage msg)
Method for retrieving the checksum of a record.
-
-
-
Field Detail
-
instance
protected static ChecksumFileServer instance
The instance of this server.
-
cs
protected ChecksumArchive cs
The archive which contain the actual data.
-
APPLICATION_ID_SEPARATOR
public static final String APPLICATION_ID_SEPARATOR
The character to separate the applicationInstanceId and the IP address.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static ChecksumFileServer getInstance()
Returns the unique instance of this class.The server creates an instance of the checksum it creates access to and starts to listen to a JMS messages on the incoming JMS queue.
Should this do the heart beats to a monitor? This would be quite odd, since Checksum does not use a monitor.
- Returns:
- This instance.
-
close
public void close()
Method for closing the instance.
-
cleanup
public void cleanup()
Method for cleaning up, when closing this instance down.- Specified by:
cleanup
in interfaceCleanupIF
- Specified by:
cleanup
in classChecksumArchiveServer
-
getAppId
public String getAppId()
Method for retrieving the identification of this application.- Specified by:
getAppId
in classChecksumArchiveServer
- Returns:
- The id of this application.
-
createAppId
protected String createAppId()
Method for creating the identification for this application.- Returns:
- The id of this application.
-
visit
public void visit(UploadMessage msg) throws ArgumentNotValid
The method for uploading arc files. Note that cleanup of the upload file embedded in the message is delegated the methodChecksumArchive.upload(RemoteFile, String)
- Specified by:
visit
in interfaceArchiveMessageVisitor
- Specified by:
visit
in classChecksumArchiveServer
- Parameters:
msg
- The upload message, containing the file to upload.- Throws:
ArgumentNotValid
- If the UploadMessage is null.
-
visit
public void visit(CorrectMessage msg) throws ArgumentNotValid
Method for correcting an entry in the archive. It start by ensuring that the file exists, then it checks the credentials. Then it is checked whether the "bad entry" does have the "bad checksum". If no problems occurred, then the bad entry will be corrected by the archive (the bad entry is removed from the archive file and put into the "wrong entry" file. Then the new entry is placed in the archive file.If it fails in any of the above, then the method fails (throws an exception which is caught and use for replying NotOk to the message).
- Specified by:
visit
in interfaceArchiveMessageVisitor
- Specified by:
visit
in classChecksumArchiveServer
- Parameters:
msg
- The message containing the correct instance of the file to correct.- Throws:
ArgumentNotValid
- If the correct message is null.
-
visit
public void visit(GetChecksumMessage msg) throws ArgumentNotValid
Method for retrieving the checksum of a record.- Specified by:
visit
in interfaceArchiveMessageVisitor
- Specified by:
visit
in classChecksumArchiveServer
- Parameters:
msg
- The GetChecksumMessage which contains the name of the record to have its checksum retrieved.- Throws:
ArgumentNotValid
- If the message is null.
-
visit
public void visit(GetAllFilenamesMessage msg) throws ArgumentNotValid
Method for retrieving all the filenames within the archive.- Specified by:
visit
in interfaceArchiveMessageVisitor
- Specified by:
visit
in classChecksumArchiveServer
- Parameters:
msg
- The GetAllFilenamesMessage.- Throws:
ArgumentNotValid
- If the GetAllFilenamesMessages is null.
-
visit
public void visit(GetAllChecksumsMessage msg) throws ArgumentNotValid
Method for retrieving a map containing all the checksums and their corresponding filenames within the archive.- Specified by:
visit
in interfaceArchiveMessageVisitor
- Specified by:
visit
in classChecksumArchiveServer
- Parameters:
msg
- The GetAllChecksumMessage.- Throws:
ArgumentNotValid
- If the GetAllChecksumMessage is null.
-
-