dk.netarkivet.archive.bitarchive
Class BitarchiveMonitor

java.lang.Object
  extended by java.util.Observable
      extended by dk.netarkivet.archive.bitarchive.BitarchiveMonitor
All Implemented Interfaces:
CleanupIF

public class BitarchiveMonitor
extends java.util.Observable
implements CleanupIF

Class representing the monitor for bitarchives. The monitor is used for sending out and combining the results of executing batch jobs. 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.


Nested Class Summary
 class BitarchiveMonitor.BatchJobStatus
          Class handling state and updates in batch job status.
 
Field Summary
 java.util.Map<java.lang.String,BitarchiveMonitor.BatchJobStatus> runningBatchJobs
          Map from the ID of batch jobs sent to bitarchives, to tuple class of status for this batch job.
 
Constructor Summary
BitarchiveMonitor()
          Initialises the bitarchive monitor.
 
Method Summary
 void bitarchiveReply(java.lang.String bitarchiveBatchID, java.lang.String bitarchiveID, int noOfFilesProcessed, java.util.Collection<java.io.File> filesFailed, RemoteFile remoteFile, java.lang.String errMsg, java.util.List<FileBatchJob.ExceptionOccurrence> exceptions)
          Handle a reply received from a bitarchive.
 void cleanup()
          Closes this BitarchiveMonitor cleanly.
 void registerBatch(java.lang.String requestID, ChannelID requestReplyTo, java.lang.String bitarchiveBatchID, long timeout)
          Register a new batch sent to the bitarchives.
 void signOfLife(java.lang.String appID)
          Registers a sign of life from a bitarchive.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

runningBatchJobs

public java.util.Map<java.lang.String,BitarchiveMonitor.BatchJobStatus> runningBatchJobs
Map from the ID of batch jobs sent to bitarchives, to tuple class of status for this batch job. The Map contains all batch jobs currently running.

Constructor Detail

BitarchiveMonitor

public BitarchiveMonitor()
Initialises the bitarchive monitor. During this, the acceptable delay between signs of life and the timeout setting for batchjobs are read and logged.

Method Detail

signOfLife

public void signOfLife(java.lang.String appID)
Registers a sign of life from a bitarchive. This method logs when new bit archives present themselves.

Parameters:
appID - the ID of the bitarchive that generated the life sign

registerBatch

public void registerBatch(java.lang.String requestID,
                          ChannelID requestReplyTo,
                          java.lang.String bitarchiveBatchID,
                          long timeout)
Register a new batch sent to the bitarchives. 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.

Parameters:
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.
Throws:
ArgumentNotValid - If any argument is null, or either string is q` empty.

bitarchiveReply

public void bitarchiveReply(java.lang.String bitarchiveBatchID,
                            java.lang.String bitarchiveID,
                            int noOfFilesProcessed,
                            java.util.Collection<java.io.File> filesFailed,
                            RemoteFile remoteFile,
                            java.lang.String errMsg,
                            java.util.List<FileBatchJob.ExceptionOccurrence> exceptions)
Handle a reply received from a bitarchive. 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.

Parameters:
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.
Throws:
ArgumentNotValid - If either ID is null.

cleanup

public void cleanup()
Closes this BitarchiveMonitor cleanly. Currently does nothing.

Specified by:
cleanup in interface CleanupIF