dk.netarkivet.archive.arcrepository
Class ArcRepository

java.lang.Object
  extended by dk.netarkivet.archive.arcrepository.ArcRepository
All Implemented Interfaces:
CleanupIF

public class ArcRepository
extends java.lang.Object
implements CleanupIF

The Arcrepository handles the communication with the different replicas. This class ensures that arc files are stored in all available replica and verifies that the storage process succeeded. Retrieval of data from a replica goes through the JMSArcRepositoryClient that contacts the appropriate (typically nearest) replica and retrieves data from this archive. Batch execution is sent to the bitarchive replica(s), since batch cannot be executed on checksum replicas. Correction operations are typically only allowed on one replica.


Constructor Summary
protected ArcRepository()
          Constructor for the ArcRepository.
 
Method Summary
 void cleanup()
          Closes all connections and nulls the instance.
 void close()
          Close all replicas connections, open loggers, and the ArcRepository handler.
static ArcRepository getInstance()
          Returns the unique ArcRepository instance.
 ReplicaClient getReplicaClientFromReplicaId(java.lang.String replicaId)
          Returns a replica client based on a replica id.
 void onBatchReply(BatchReplyMessage msg)
          Called when we receive replies on our checksum batch jobs.
 void onChecksumReply(GetChecksumMessage msg)
          The message for handling the results of the GetChecksumMessage.
 void onUpload(UploadMessage msg)
          Event handler for upload messages reporting the upload result.
 void removeAndGetFile(RemoveAndGetFileMessage msg)
          Forwards a RemoveAndGetFileMessage to the designated bitarchive.
 void store(RemoteFile rf, StoreMessage replyInfo)
          Stores a file in all known replicas.
 void updateAdminData(AdminDataMessage msg)
          Change admin data entry for a given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArcRepository

protected ArcRepository()
                 throws IOFailure,
                        IllegalState
Constructor for the ArcRepository. Connects the ArcRepository to all BitArchives, and initialises admin data.

Throws:
IOFailure - if admin data cannot be read/initialised or we cannot' connect to some bitarchive.
IllegalState - if inconsistent channel info is given in settings.
Method Detail

getInstance

public static ArcRepository getInstance()
                                 throws IllegalState,
                                        IOFailure
Returns the unique ArcRepository instance.

Returns:
the instance.
Throws:
IOFailure - if admin data cannot be read/initialised or we cannot' connect to some bitarchive.
IllegalState - if inconsistent channel info is given in settings.

store

public void store(RemoteFile rf,
                  StoreMessage replyInfo)
           throws IOFailure,
                  ArgumentNotValid
Stores a file in all known replicas. It sends out a upload message to all replicas.

Parameters:
rf - The remotefile to be stored.
replyInfo - A StoreMessage used to reply with success or failure.
Throws:
IOFailure - If file couldn't be stored.
ArgumentNotValid - If a input parameter is null.

getReplicaClientFromReplicaId

public ReplicaClient getReplicaClientFromReplicaId(java.lang.String replicaId)
                                            throws ArgumentNotValid
Returns a replica client based on a replica id.

Parameters:
replicaId - the replica id
Returns:
A replica client.
Throws:
ArgumentNotValid - if replicaId parameter is null

onUpload

public void onUpload(UploadMessage msg)
Event handler for upload messages reporting the upload result. Checks the success status of the upload and updates admin data accordingly.

Parameters:
msg - an UploadMessage.

onBatchReply

public void onBatchReply(BatchReplyMessage msg)
Called when we receive replies on our checksum batch jobs. This does not handle checksum replicas.

Parameters:
msg - a BatchReplyMessage.

onChecksumReply

public void onChecksumReply(GetChecksumMessage msg)
The message for handling the results of the GetChecksumMessage.

Parameters:
msg - The message containing the checksum of a specific file.

updateAdminData

public void updateAdminData(AdminDataMessage msg)
Change admin data entry for a given file. The following information is contained in the given AdminDataMessage: 1) The name of the given file to change the entry for, 2) the name of the bitarchive to modify the entry for, 3) a boolean that says whether or not to replace the checksum for the entry for the given file in AdminData, 4) a replacement for the case where the former value is true.

Parameters:
msg - an AdminDataMessage object

removeAndGetFile

public void removeAndGetFile(RemoveAndGetFileMessage msg)
Forwards a RemoveAndGetFileMessage to the designated bitarchive. Before forwarding the message it is verified that the checksum of the file to remove differs from the registered checksum of the file to remove. If no registration exists for the file to remove the message is always forwarded.

Parameters:
msg - the message to forward to a bitarchive

close

public void close()
Close all replicas connections, open loggers, and the ArcRepository handler.


cleanup

public void cleanup()
Closes all connections and nulls the instance. The ArcRepositoryHandler, the AdminData and the ReplicaClients are closed along with all their connections.

Specified by:
cleanup in interface CleanupIF