dk.netarkivet.archive.bitarchive.distribute
Class BitarchiveMonitorServer

java.lang.Object
  extended by dk.netarkivet.archive.distribute.ArchiveMessageHandler
      extended by dk.netarkivet.archive.bitarchive.distribute.BitarchiveMonitorServer
All Implemented Interfaces:
ArchiveMessageVisitor, CleanupIF, java.util.Observer, javax.jms.MessageListener

public class BitarchiveMonitorServer
extends ArchiveMessageHandler
implements java.util.Observer, CleanupIF

Class representing message handling for the monitor for bitarchives. The monitor is used for sending out and combining the results of executing batch jobs. Batch jobs are received on the BAMON-channel, and resent to all bitarchives, that are considered live by the bitarchive monitor. Lets the bitarchive monitor handle batch replies from the bitarchives, and observes it for when the batch job is done. Then constructs a reply from the data given, and sends it back to the originator. Also registers signs of life from the bitarchives in the bitarchive monitor.


Constructor Summary
protected BitarchiveMonitorServer()
          Creates an instance of a BitarchiveMonitorServer.
 
Method Summary
 void cleanup()
          Closes this BitarchiveMonitorServer cleanly.
 void close()
          Close down this BitarchiveMonitor.
static BitarchiveMonitorServer getInstance()
          Returns the unique instance of a BitarchiveMonitorServer.
 void update(java.util.Observable o, java.lang.Object arg)
          Handles notifications from the bitarchive monitor, that a batch job is complete.
 void visit(BatchEndedMessage beMsg)
          This is the message handling method for BatchEndedMessages.
 void visit(BatchMessage inbMsg)
          This is the message handling method for BatchMessages.
 void visit(HeartBeatMessage hbMsg)
          This is the message handling method for HeartBeatMessages.
 
Methods inherited from class dk.netarkivet.archive.distribute.ArchiveMessageHandler
onMessage, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitarchiveMonitorServer

protected BitarchiveMonitorServer()
                           throws IOFailure
Creates an instance of a BitarchiveMonitorServer.

Throws:
IOFailure - - if an error with the JMSConnection occurs
Method Detail

getInstance

public static BitarchiveMonitorServer getInstance()
                                           throws IOFailure
Returns the unique instance of a BitarchiveMonitorServer.

Returns:
the instance
Throws:
IOFailure - - if an error with the JMSConnection occurs

visit

public void visit(BatchMessage inbMsg)
This is the message handling method for BatchMessages. A new BatchMessage is created with the same Job as the incoming BatchMessage and sent off to all live bitarchives. The incoming and outgoing batch messages are then registered at the bitarchive monitor.

Specified by:
visit in interface ArchiveMessageVisitor
Overrides:
visit in class ArchiveMessageHandler
Parameters:
inbMsg - The message received

visit

public void visit(BatchEndedMessage beMsg)
This is the message handling method for BatchEndedMessages. This delegates the handling of the reply to the bitarhcive monitor, which will notify us if the batch job is now done.

Specified by:
visit in interface ArchiveMessageVisitor
Overrides:
visit in class ArchiveMessageHandler
Parameters:
beMsg -

visit

public void visit(HeartBeatMessage hbMsg)
This is the message handling method for HeartBeatMessages. Registers a sign of life from a bitarchive.

Specified by:
visit in interface ArchiveMessageVisitor
Overrides:
visit in class ArchiveMessageHandler
Parameters:
hbMsg - the message that represents the sign of life

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Handles notifications from the bitarchive monitor, that a batch job is complete. Spawns a new thread in which all the results are wrapped and sent back in a reply to the originator of this batch request.

Specified by:
update in interface java.util.Observer
Parameters:
o - the observable object. Should always be the bitarchive monitor. If it isn't, this notification will be logged and ignored.
arg - an argument passed from the bitarchive monitor. This should always be a batch status object indicating the end of that batchjob. If it isn't, this notification will be logged and ignored.

close

public void close()
Close down this BitarchiveMonitor.


cleanup

public void cleanup()
Closes this BitarchiveMonitorServer cleanly.

Specified by:
cleanup in interface CleanupIF