dk.netarkivet.archive.checksum.distribute
Class ChecksumClient

java.lang.Object
  extended by dk.netarkivet.archive.checksum.distribute.ChecksumClient
All Implemented Interfaces:
ReplicaClient

public class ChecksumClient
extends java.lang.Object
implements ReplicaClient

Proxy for remote checksum archive. Establishes the jms connection to the remote checksum archive. Can be used in combination with any type of ChecksumServerAPI.


Field Summary
protected static org.apache.commons.logging.Log log
          The log.
 
Method Summary
 BatchMessage batch(BatchMessage msg)
          Method for sending batch job messages to the replica.
 BatchMessage batch(ChannelID replyChannel, FileBatchJob job)
          Method for sending batch job messages to the replica.
 void close()
          Method for closing this instance.
 void correct(CorrectMessage msg)
          Method for sending correct messages to the replica.
 void get(GetMessage msg)
          This method is intended to retrieve a record from an arc-file within the archive.
 void getAllChecksums(GetAllChecksumsMessage msg)
          Method for sending the GetAllChecksumMessage to the ChecksumReplica.
 void getAllFilenames(GetAllFilenamesMessage msg)
          Method for sending a GetAllFilenamesMessage to a checksum archive.
 GetChecksumMessage getChecksum(ChannelID replyChannel, java.lang.String filename)
          Method for retrieving the checksum of a specific arcfile within the archive.
 void getChecksum(GetChecksumMessage msg)
          Method for retrieving the checksum of a specific arcfile within the archive.
 void getFile(GetFileMessage gfm)
          This method is intended to retrieve an arc-file from the archive.
static ChecksumClient getInstance(ChannelID theCRin)
          The method for retrieving the invoked the instance.
 ReplicaType getType()
          Method for retrieving the type of replica.
 void removeAndGetFile(RemoveAndGetFileMessage msg)
          This method is intended to retrieve an arc-file from the archive.
 void upload(RemoteFile rf)
          Method for uploading a file to the archive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
The log.

Method Detail

getInstance

public static ChecksumClient getInstance(ChannelID theCRin)
                                  throws IOFailure,
                                         ArgumentNotValid
The method for retrieving the invoked the instance. If not invoked yet, then invoke.

Parameters:
theCRin - The channel for contacting the checksum archive.
Returns:
The instance.
Throws:
IOFailure - If there is a problem with the connection.
ArgumentNotValid - If the checksum replica channel is null.

correct

public void correct(CorrectMessage msg)
             throws ArgumentNotValid
Method for sending correct messages to the replica. This CorrectMessage is used to correct a bad entry in the archive.

Specified by:
correct in interface ReplicaClient
Parameters:
msg - The CorrectMessage to send to the replica.
Throws:
ArgumentNotValid - If the CorrectMessage is null.

getAllFilenames

public void getAllFilenames(GetAllFilenamesMessage msg)
                     throws ArgumentNotValid
Method for sending a GetAllFilenamesMessage to a checksum archive.

Specified by:
getAllFilenames in interface ReplicaClient
Parameters:
msg - The GetAllFilenamesMessage, which will be send through the jms connection to the checksum archive.
Throws:
ArgumentNotValid - If the GetAllFilenamesMessage is null.

getAllChecksums

public void getAllChecksums(GetAllChecksumsMessage msg)
                     throws ArgumentNotValid
Method for sending the GetAllChecksumMessage to the ChecksumReplica.

Specified by:
getAllChecksums in interface ReplicaClient
Parameters:
msg - The GetAllChecksumMessage, which will be sent through the jms connection to the checksum archive.
Throws:
ArgumentnotValid - If the GetAllChecksumsMessage is null.
ArgumentNotValid

getChecksum

public void getChecksum(GetChecksumMessage msg)
Method for retrieving the checksum of a specific arcfile within the archive.

Specified by:
getChecksum in interface ReplicaClient
Parameters:
msg - The GetChecksumMessage which will be sent to the checksum archive though the jms connection.

getChecksum

public GetChecksumMessage getChecksum(ChannelID replyChannel,
                                      java.lang.String filename)
                               throws ArgumentNotValid
Method for retrieving the checksum of a specific arcfile within the archive.

Specified by:
getChecksum in interface ReplicaClient
Parameters:
replyChannel - The channel where the reply should be sent.
filename - The GetChecksumMessage which has been sent to the checksum archive though the jms connection.
Returns:
The GetChecksumMessage which is sent.
Throws:
ArgumentNotValid - If the reply channel is null or if the filename is either null or the empty string.

getType

public ReplicaType getType()
Method for retrieving the type of replica. In this case the replica is a checksum replica.

Specified by:
getType in interface ReplicaClient
Returns:
The type of this replica, in this case Checksum replica.

upload

public void upload(RemoteFile rf)
            throws ArgumentNotValid
Method for uploading a file to the archive. This is only uploaded to one of the archives, not all of them. Thus using the 'any' channel.

Specified by:
upload in interface ReplicaClient
Parameters:
rf - The file to upload to the archive.
Throws:
ArgumentNotValid - If the remote file is null.

batch

public BatchMessage batch(ChannelID replyChannel,
                          FileBatchJob job)
                   throws IllegalState,
                          ArgumentNotValid
Method for sending batch job messages to the replica. This is not allowed since this archive at the end of this client is a checksum archive, which cannot handle batch jobs.

Specified by:
batch in interface ReplicaClient
Parameters:
replyChannel - The channel where the reply should be sent.
job - The batchjob to execute.
Returns:
Nothing. It always throws an exception, since it is not allowed to run batchjobs on a checksum archive.
Throws:
IllegalState - Always. Since it is not legal to send a batchjob to a checksum replica.
ArgumentNotValid - If the channel or the batchjob is null.

batch

public BatchMessage batch(BatchMessage msg)
                   throws IllegalState,
                          ArgumentNotValid
Method for sending batch job messages to the replica. This is not allowed since this archive at the end of this client is a checksum archive, which cannot handle batch jobs.

Specified by:
batch in interface ReplicaClient
Parameters:
msg - The batch message.
Returns:
Nothing. It always throws an exception, since it is not allowed to run batchjobs on a checksum archive.
Throws:
IllegalState - Always. Since it is not legal to send a batchjob to a checksum replica.
ArgumentNotValid - If the message is null.

get

public void get(GetMessage msg)
         throws IllegalState,
                ArgumentNotValid
This method is intended to retrieve a record from an arc-file within the archive. But since this handles checksum archive, it does not have the actual arc-files, and this function should therefore fail.

Specified by:
get in interface ReplicaClient
Parameters:
msg - The GetMessage for retrieving the arc-record from the archive.
Throws:
IllegalState - Always. Since checksum replicas cannot handle this kind of messages.
ArgumentNotValid - If the message is null.

getFile

public void getFile(GetFileMessage gfm)
             throws IllegalState,
                    ArgumentNotValid
This method is intended to retrieve an arc-file from the archive. But since this handles checksum archive, it does not have the actual arc-files, and this function should therefore fail.

Specified by:
getFile in interface ReplicaClient
Parameters:
gfm - The GetFileMessage for retrieving the arc-file from the archive.
Throws:
IllegalState - Always. Since checksum replicas cannot handle this kind of messages.
ArgumentNotValid - If the message is null.

removeAndGetFile

public void removeAndGetFile(RemoveAndGetFileMessage msg)
                      throws IllegalState,
                             ArgumentNotValid
This method is intended to retrieve an arc-file from the archive. But since this handles checksum archive, it does not have the actual arc-files, and this function should therefore fail.

Specified by:
removeAndGetFile in interface ReplicaClient
Parameters:
msg - The RemoveAndGetFileMessage for removing and retrieving an arc-file from the archive.
Throws:
IllegalState - Always. Since checksum replicas cannot handle this kind of messages.
ArgumentNotValid - If the message is null.

close

public void close()
Method for closing this instance.

Specified by:
close in interface ReplicaClient