dk.netarkivet.archive.bitarchive.distribute
Class BitarchiveClient

java.lang.Object
  extended by dk.netarkivet.archive.bitarchive.distribute.BitarchiveClient
All Implemented Interfaces:
ReplicaClient

public final class BitarchiveClient
extends java.lang.Object
implements ReplicaClient

Proxy for remote bitarchive. Establishes a JMS connection to the remote bitarchive.


Method Summary
 void close()
          Release jms connections.
 GetMessage get(java.lang.String arcfile, long index)
          Submit a get request to the bitarchive.
static BitarchiveClient getInstance(ChannelID allBaIn, ChannelID anyBaIn, ChannelID theBamonIn)
          Factory that establish the connection to the server.
 ReplicaType getType()
          Retrieves the type of replica.
 BatchMessage sendBatchJob(BatchMessage bMsg)
          Submit an already constructed get message to the archive.
 BatchMessage sendBatchJob(ChannelID replyChannel, FileBatchJob job)
          Submit a batch job to the archive.
 void sendBatchTerminationMessage(java.lang.String batchID)
          Sends a message to terminate a running batchjob.
 void sendCorrectMessage(CorrectMessage msg)
          For correcting an erroneous entry in the archive.
 void sendGetAllChecksumsMessage(GetAllChecksumsMessage msg)
          Method for sending the GetAllChecksumMessage to the ChecksumReplica.
 void sendGetAllFilenamesMessage(GetAllFilenamesMessage msg)
          Method for sending a GetAllFilenamesMessage to a checksum archive.
 GetChecksumMessage sendGetChecksumMessage(ChannelID replyChannel, java.lang.String filename)
          Method for retrieving the checksum of a specific arcfile within the archive.
 void sendGetChecksumMessage(GetChecksumMessage msg)
          Method for retrieving the checksum of a specific arcfile within the archive.
 void sendGetFileMessage(GetFileMessage msg)
          Submit an already constructed getfile message to the archive.
 void sendGetMessage(GetMessage msg)
          Submit an already constructed batch message to the archive.
 void sendRemoveAndGetFileMessage(RemoveAndGetFileMessage msg)
          Forward the message to ALL_BA.
 void sendUploadMessage(RemoteFile rf)
          Submit an upload request to the bitarchive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static BitarchiveClient getInstance(ChannelID allBaIn,
                                           ChannelID anyBaIn,
                                           ChannelID theBamonIn)
                                    throws IOFailure
Factory that establish the connection to the server.

Parameters:
allBaIn - topic to all bitarchives
anyBaIn - queue to one of the bitarchives
theBamonIn - queue to the bitarchive monitor
Returns:
A BitarchiveClient
Throws:
IOFailure - If there is a problem making the connection.

get

public GetMessage get(java.lang.String arcfile,
                      long index)
Submit a get request to the bitarchive.

Parameters:
arcfile - The file containing the requested record
index - Offset of the ARC record in the file
Returns:
The submitted message or null if an error occured

sendGetMessage

public void sendGetMessage(GetMessage msg)
Submit an already constructed batch message to the archive. The reply goes directly back to whoever sent the message.

Specified by:
sendGetMessage in interface ReplicaClient
Parameters:
msg - the message to be processed by the get command.

sendGetFileMessage

public void sendGetFileMessage(GetFileMessage msg)
Submit an already constructed getfile message to the archive.

Specified by:
sendGetFileMessage in interface ReplicaClient
Parameters:
msg - get file message to retrieve.

sendRemoveAndGetFileMessage

public void sendRemoveAndGetFileMessage(RemoveAndGetFileMessage msg)
Forward the message to ALL_BA.

Specified by:
sendRemoveAndGetFileMessage in interface ReplicaClient
Parameters:
msg - the message to forward.

sendBatchTerminationMessage

public void sendBatchTerminationMessage(java.lang.String batchID)
                                 throws ArgumentNotValid
Sends a message to terminate a running batchjob.

Parameters:
batchID - The ID of the batchjob to terminate.
Throws:
ArgumentNotValid - If the batchID is either null or the empty string.

sendUploadMessage

public void sendUploadMessage(RemoteFile rf)
                       throws IOFailure,
                              ArgumentNotValid
Submit an upload request to the bitarchive.

Specified by:
sendUploadMessage in interface ReplicaClient
Parameters:
rf - The file to upload.
Throws:
IOFailure - If access to file denied.
ArgumentNotValid - If arcfile is null.

sendBatchJob

public BatchMessage sendBatchJob(BatchMessage bMsg)
                          throws ArgumentNotValid
Submit an already constructed get message to the archive. This is used by the ArcRepository when forwarding batch jobs from its clients.

Specified by:
sendBatchJob in interface ReplicaClient
Parameters:
bMsg - a BatchMessage.
Returns:
The submitted message.
Throws:
ArgumentNotValid - If message is null.

sendBatchJob

public BatchMessage sendBatchJob(ChannelID replyChannel,
                                 FileBatchJob job)
                          throws ArgumentNotValid,
                                 IOFailure
Submit a batch job to the archive. This is used by the ArcRepository when it needs to run batch jobs for its own reasons, i.e. when checksumming a file as part of the Store operation.

Specified by:
sendBatchJob in interface ReplicaClient
Parameters:
replyChannel - The channel that the reply of this job should be sent to.
job - The job that should be run on the bit archive handled by this client.
Returns:
The submitted message.
Throws:
ArgumentNotValid - If any parameter was null.
IOFailure - If sending the batch message did not succeed.

close

public void close()
Release jms connections.

Specified by:
close in interface ReplicaClient

sendCorrectMessage

public void sendCorrectMessage(CorrectMessage msg)
                        throws ArgumentNotValid
For correcting an erroneous entry in the archive. The message is sent the replica for correcting the 'bad' entry.

Specified by:
sendCorrectMessage in interface ReplicaClient
Parameters:
msg - The correct message to correct the bad entry in the archive.
Throws:
ArgumentNotValid - If the CorrectMessage is null.

sendGetAllFilenamesMessage

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

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

sendGetAllChecksumsMessage

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

Specified by:
sendGetAllChecksumsMessage 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.

sendGetChecksumMessage

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

Specified by:
sendGetChecksumMessage in interface ReplicaClient
Parameters:
msg - The GetChecksumMessage which will be sent to the checksum archive though the jms connection.
Throws:
ArgumentNotValid - If the GetChecksumMessage is null.

sendGetChecksumMessage

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

Specified by:
sendGetChecksumMessage 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()
Retrieves the type of replica.

Specified by:
getType in interface ReplicaClient
Returns:
The type of this replica. In this case Bitarchive.