dk.netarkivet.archive.bitarchive.distribute
Class BitarchiveClient

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

public class BitarchiveClient
extends java.lang.Object
implements ReplicaClient

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


Field Summary
protected static org.apache.commons.logging.Log log
          The log.
 
Method Summary
 BatchMessage batch(BatchMessage bMsg)
          Submit an already constructed get message to the archive.
 BatchMessage batch(ChannelID replyChannel, FileBatchJob job)
          Submit a batch job to the archive.
 void close()
          Release jms connections.
 void correct(CorrectMessage msg)
          For correcting an erroneous entry in the archive.
 void get(GetMessage msg)
          Submit an already constructed batch message to the archive.
 GetMessage get(java.lang.String arcfile, long index)
          Submit a get request to the bitarchive.
 void getAllChecksums(GetAllChecksumsMessage msg)
          This should creates a batch job for retrieving the checksum of all the files.
 void getAllFilenames(GetAllFilenamesMessage msg)
          This should creates a batch job for retrieving all the filenames.
 GetChecksumMessage getChecksum(ChannelID replyChannel, java.lang.String filename)
          This should creates a batch job for retrieving the checksum of the wanted files.
 void getChecksum(GetChecksumMessage msg)
          This should creates a batch job for retrieving the checksum of the wanted files.
 void getFile(GetFileMessage msg)
          Submit an already constructed getfile message to the archive.
static BitarchiveClient getInstance(ChannelID all_ba_in, ChannelID any_ba_in, ChannelID the_bamon_in)
          Factory that establish the connection to the server.
 ReplicaType getType()
          Retrieves the type of replica.
 void removeAndGetFile(RemoveAndGetFileMessage msg)
          Forward the message to ALL_BA.
 void upload(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
 

Field Detail

log

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

Method Detail

getInstance

public static BitarchiveClient getInstance(ChannelID all_ba_in,
                                           ChannelID any_ba_in,
                                           ChannelID the_bamon_in)
                                    throws IOFailure
Factory that establish the connection to the server.

Parameters:
all_ba_in - topic to all bitarchives
any_ba_in - queue to one of the bitarchives
the_bamon_in - 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

get

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

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

getFile

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

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

removeAndGetFile

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

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

upload

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

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

batch

public BatchMessage batch(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:
batch in interface ReplicaClient
Parameters:
bMsg - a BatchMessage.
Returns:
The submitted message.
Throws:
ArgumentNotValid - If message is null.

batch

public BatchMessage batch(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:
batch 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

correct

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

Specified by:
correct in interface ReplicaClient
Parameters:
msg - The correct message to correct the bad entry in the archive.
Throws:
NotImplementedException - Always, since this method has not yet been implemented.
ArgumentNotValid - If the CorrectMessage is null.

getAllFilenames

public void getAllFilenames(GetAllFilenamesMessage msg)
                     throws NotImplementedException,
                            ArgumentNotValid
This should creates a batch job for retrieving all the filenames.

Specified by:
getAllFilenames in interface ReplicaClient
Parameters:
msg - The message.
Throws:
NotImplementedException - Always, since this method has not yet been implemented.
ArgumentNotValid - If the GetAllFilenamesMessage is null.

getAllChecksums

public void getAllChecksums(GetAllChecksumsMessage msg)
                     throws NotImplementedException,
                            ArgumentNotValid
This should creates a batch job for retrieving the checksum of all the files.

Specified by:
getAllChecksums in interface ReplicaClient
Parameters:
msg - The message.
Throws:
NotImplementedException - Always, since this method has not yet been implemented.
ArgumentNotValid - If the GetAllChecksumMessage is null.

getChecksum

public void getChecksum(GetChecksumMessage msg)
                 throws NotImplementedException,
                        ArgumentNotValid
This should creates a batch job for retrieving the checksum of the wanted files.

Specified by:
getChecksum in interface ReplicaClient
Parameters:
msg - The message.
Throws:
NotImplementedException - Always, since this method has not yet been implemented.
ArgumentNotValid - If the GetChecksumMessage is null.

getChecksum

public GetChecksumMessage getChecksum(ChannelID replyChannel,
                                      java.lang.String filename)
                               throws NotImplementedException,
                                      ArgumentNotValid
This should creates a batch job for retrieving the checksum of the wanted files.

Specified by:
getChecksum in interface ReplicaClient
Parameters:
replyChannel - The channel where the reply should be sent.
filename - The name of the file to retrieve the checksum from.
Returns:
The message when it has been sent.
Throws:
NotImplementedException - Always, since it has not yet been implemented.
ArgumentNotValid - If the replyChannel is null or the filename either is null or empty.

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.