public class BitarchiveMonitor extends Observable implements CleanupIF
Registers outgoing batchjobs to bitarchives, and handles replies from bitarchives, finally notifying observers when all bitarchives have replied, or when the batch times out, after a time specified in settings.
We wait for replies from bitarchives that are considered live when the batch begins. A bitarchive is considered live if we have heard any activity from it within a time specified in settings.
Modifier and Type | Class and Description |
---|---|
class |
BitarchiveMonitor.BatchJobStatus
Class handling state and updates in batch job status.
|
Modifier and Type | Field and Description |
---|---|
protected Timer |
batchTimer
The timer for keeping track of running batchjobs.
|
Modifier and Type | Method and Description |
---|---|
void |
bitarchiveReply(String bitarchiveBatchID,
String bitarchiveID,
int noOfFilesProcessed,
Collection<File> filesFailed,
RemoteFile remoteFile,
String errMsg,
List<FileBatchJob.ExceptionOccurrence> exceptions)
Handle a reply received from a bitarchive.
|
void |
cleanup()
Closes this BitarchiveMonitor cleanly.
|
static BitarchiveMonitor |
getInstance()
Method for retrieving the current instance.
|
void |
registerBatch(String requestID,
ChannelID requestReplyTo,
String bitarchiveBatchID,
long timeout)
Register a new batch sent to the bitarchives.
|
void |
signOfLife(String appID)
Registers a sign of life from a bitarchive.
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
protected final Timer batchTimer
public static BitarchiveMonitor getInstance()
public void signOfLife(String appID)
appID
- the ID of the bitarchive that generated the life signpublic void registerBatch(String requestID, ChannelID requestReplyTo, String bitarchiveBatchID, long timeout) throws ArgumentNotValid
This registers a new batchstatus object, with a list of live bitarchives awaiting reply, and a timer task letting the job time out after the specified time.
requestID
- The ID of the batch request.requestReplyTo
- The replyTo channel of the batch request.bitarchiveBatchID
- The ID of the batch job sent on to the bit archives.timeout
- Timeout of specific batch job.ArgumentNotValid
- If any argument is null, or either string is empty.public void bitarchiveReply(String bitarchiveBatchID, String bitarchiveID, int noOfFilesProcessed, Collection<File> filesFailed, RemoteFile remoteFile, String errMsg, List<FileBatchJob.ExceptionOccurrence> exceptions) throws ArgumentNotValid
This method registers the information from the bitarchive in the batch status for this job, if any (otherwise logs and quits).
If this is the last bitarchive we were missing replies from, notify observers with the batch status for this job.
TODO why are the 'exceptions' argument not used?
bitarchiveBatchID
- The ID of the batch job sent on to the bit archives.bitarchiveID
- The ID of the replying bitarchive.noOfFilesProcessed
- The number of files the bitarchive has processed.filesFailed
- A collection of filenames of failed files in that bitarchive. Might be null if no files
failed.remoteFile
- A remote pointer to a file with results from that bitarchive. Might be null if job was not OK.errMsg
- An error message, if the job was not successful on the bitarchive, or null for none.exceptions
- A list of exceptions caught during batch processing.ArgumentNotValid
- If either ID is null.Copyright © 2005–2015 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.