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 bitarchives. The Arcrepository ensures that arc files are stored in all available bitarchives and verifies that the storage process succeeded Retrieval of data from a bitarchive goes through the JMSArcRepositoryClient that contacts the appropriate (typically nearest) bitarchive and retrieves data from this archive. Batch execution is sent to the appropriate bitarchive(s) Correction operations are typically only allowed on one bitarchive.


Method Summary
 void cleanup()
          closes all connections and nulls the instance.
 void close()
          Close all bitarchive connections, open loggers, and the ArcRepository handler.
 BitarchiveClient getBitarchiveClientFromLocationName(java.lang.String locationName)
          Returns a bitarchive client based on a location name.
static ArcRepository getInstance()
          Returns the unique ArcRepository instance.
 void onBatchReply(BatchReplyMessage msg)
          Called when we receive replies on our checksum batch jobs.
 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 Bitarchives.
 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
 

Method Detail

getInstance

public static ArcRepository getInstance()
                                 throws PermissionDenied,
                                        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.
PermissionDenied - if inconsistent channel info is given in settings.

store

public void store(RemoteFile rf,
                  StoreMessage replyInfo)
           throws IOFailure
Stores a file in all known Bitarchives. This runs asynchronously, and returns immediately. Sideeffects: 1) The RemoteFile added to List outstandingRemoteFiles 2) TODO: Document other sideeffects.

Parameters:
rf - A remotefile to be stored.
replyInfo - A StoreMessage used to reply with succes or failure.
Throws:
IOFailure - If file couldn't be stores.

getBitarchiveClientFromLocationName

public BitarchiveClient getBitarchiveClientFromLocationName(java.lang.String locationName)
                                                     throws ArgumentNotValid
Returns a bitarchive client based on a location name.

Parameters:
locationName - the location name
Returns:
a bitarchive client a bitarchive client
Throws:
ArgumentNotValid - if locationName 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.

Parameters:
msg - a BatchReplyMessage

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 bitarchive connections, open loggers, and the ArcRepository handler.


cleanup

public void cleanup()
closes all connections and nulls the instance.

Specified by:
cleanup in interface CleanupIF