Class BitarchiveMonitorServer
- java.lang.Object
-
- dk.netarkivet.archive.distribute.ArchiveMessageHandler
-
- dk.netarkivet.archive.bitarchive.distribute.BitarchiveMonitorServer
-
- All Implemented Interfaces:
ArchiveMessageVisitor
,CleanupIF
,Observer
,javax.jms.MessageListener
public class BitarchiveMonitorServer extends ArchiveMessageHandler implements 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
Constructors Modifier Constructor Description protected
BitarchiveMonitorServer()
Creates an instance of a BitarchiveMonitorServer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Closes this BitarchiveMonitorServer cleanly.void
close()
Close down this BitarchiveMonitor.static BitarchiveMonitorServer
getInstance()
Returns the unique instance of a BitarchiveMonitorServer.void
update(Observable o, 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.void
visit(RemoveAndGetFileMessage msg)
This is the second step in correcting a bad entry.void
visit(UploadMessage msg)
This is the third step in correcting a bad entry.void
visit(CorrectMessage cm)
This is the first step in correcting a bad entry.void
visit(GetAllChecksumsMessage msg)
Method for handling the GetAllChecksumsMessage.void
visit(GetAllFilenamesMessage msg)
Method for handling the GetAllFilenamesMessage.void
visit(GetChecksumMessage msg)
Method for handling the GetChecksumMessage.
-
-
-
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) throws ArgumentNotValid
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 interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
inbMsg
- The message received- Throws:
ArgumentNotValid
- If the BatchMessage is null.
-
visit
public void visit(BatchEndedMessage beMsg) throws ArgumentNotValid
This is the message handling method for BatchEndedMessages.This delegates the handling of the reply to the bitarchive monitor, which will notify us if the batch job is now done.
- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
beMsg
- The BatchEndedMessage to be handled.- Throws:
ArgumentNotValid
- If the BatchEndedMessage is null.
-
visit
public void visit(HeartBeatMessage hbMsg) throws ArgumentNotValid
This is the message handling method for HeartBeatMessages.Registers a sign of life from a bitarchive.
- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
hbMsg
- the message that represents the sign of life- Throws:
ArgumentNotValid
- If the HeartBeatMessage is null.
-
visit
public void visit(CorrectMessage cm) throws ArgumentNotValid
This is the first step in correcting a bad entry.In the first stage, a RemoveAndGetFileMessage is sent, and then the CorrectMessage is put in the map along the ID of the RemoveAndGetFileMessage.
See the correctMessages Map.
- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
cm
- The CorrectMessage to handle.- Throws:
ArgumentNotValid
- If the CorrectMessage is null.
-
visit
public void visit(RemoveAndGetFileMessage msg) throws ArgumentNotValid
This is the second step in correcting a bad entry.In the second stage, the reply of the RemoveAndGetFileMessage is used to extract the CorrectMessage from the Map. The CorrectMessage is then updated with the results from the RemoveAndGetFileMessage. Then an UploadMessage is send with the 'correct' file, where the ID of the UploadMessage is put into the map along the CorrectMessage.
See the correctMessages Map.
- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- The RemoteAndGetFileMessage.- Throws:
ArgumentNotValid
- If the RemoveAndGetFileMessage is null.
-
visit
public void visit(UploadMessage msg) throws ArgumentNotValid
This is the third step in correcting a bad entry.In the third stage, the reply of the UploadMessage is used to extract the CorrectMessage from the map again, and the results of the UploadMessage is used to update the UploadMessage, which is then returned.
See the correctMessages Map.
- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- The reply of the UploadMessage.- Throws:
ArgumentNotValid
- If the UploadMessage is null.
-
visit
public void visit(GetAllChecksumsMessage msg) throws ArgumentNotValid
Method for handling the GetAllChecksumsMessage. This message will be made into a batchjob, which will executed on the bitarchives. The reply to the batchjob will be handled and uses as reply to the GetAllChecksumsMessage.- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- The GetAllChecksumsMessage, which will be made into a batchjob and sent to the bitarchives.- Throws:
ArgumentNotValid
- If the GetAllChecksumsMessage is null.
-
visit
public void visit(GetAllFilenamesMessage msg) throws ArgumentNotValid
Method for handling the GetAllFilenamesMessage. The GetAllFilenamesMessage will be made into a filelist batchjob, which will be sent to the bitarchives. The reply to the batchjob will then be used as reply to the GetAllFilenamesMessage.- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- The GetAllFilenamesMessage, which will be made into a batchjob and sent to the bitarchives.- Throws:
ArgumentNotValid
- If the GetAllFilenamesMessage is null.
-
visit
public void visit(GetChecksumMessage msg) throws ArgumentNotValid
Method for handling the GetChecksumMessage. This is made into the batchjob ChecksumsJob which will be limitted to the specific filename. The batchjob will be executed on the bitarchives and the reply to the batchjob will be used as reply to the GetChecksumMessage.- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- The GetAllChecksumsMessage, which will be made into a batchjob and sent to the bitarchives.- Throws:
ArgumentNotValid
- If the GetChecksumMessage is null.
-
update
public void update(Observable o, 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 interfaceObserver
- 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.
-
-