dk.netarkivet.archive.bitarchive.distribute
Class BitarchiveServer

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

public class BitarchiveServer
extends ArchiveMessageHandler
implements CleanupIF

Bitarchive container responsible for processing the different classes of message which can be received by a bitarchive and returning appropriate data.


Method Summary
 void cleanup()
          Ends the heartbeat sender before next loop.
 void close()
          Ends the heartbeat sender before next loop and removes the server as listener on allBa and anyBa.
 java.lang.String getBitarchiveAppId()
          Returns a String that identifies this bit archive application (within the bit archive, i.e.
static BitarchiveServer getInstance()
          Returns the unique instance of this class The server creates an instance of the bitarchive it provides access to and starts to listen to JMS messages on the incomming jms queue

Also, heartbeats are sent out at regular intervals to the Bitarchive Monitor, to tell that this bitarchive is alive.

 void visit(BatchMessage msg)
          Process a batch job and send the result back to the client.
 void visit(GetFileMessage msg)
          Process a getFile request and send the result back to the client.
 void visit(GetMessage msg)
          Process a get request and send the result back to the client.
 void visit(RemoveAndGetFileMessage msg)
          Removes an arcfile from the bitarchive and returns the removed file as an remotefile.
 void visit(UploadMessage msg)
          Process a upload request and send the result back to the client.
 
Methods inherited from class dk.netarkivet.archive.distribute.ArchiveMessageHandler
onMessage, visit, visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static BitarchiveServer getInstance()
Returns the unique instance of this class The server creates an instance of the bitarchive it provides access to and starts to listen to JMS messages on the incomming jms queue

Also, heartbeats are sent out at regular intervals to the Bitarchive Monitor, to tell that this bitarchive is alive.

Returns:
the instance
Throws:
UnknownID - - if there was no heartbeat frequency defined in settings
ArgumentNotValid - - if the heartbeat frequency in settings is invalid or either argument is null

close

public void close()
Ends the heartbeat sender before next loop and removes the server as listener on allBa and anyBa. Clsoes bitarchive.


cleanup

public void cleanup()
Ends the heartbeat sender before next loop.

Specified by:
cleanup in interface CleanupIF

visit

public void visit(GetMessage msg)
Process a get request and send the result back to the client. If the arcfile is not found on this bitarchive machine, nothing happens.

Specified by:
visit in interface ArchiveMessageVisitor
Overrides:
visit in class ArchiveMessageHandler
Parameters:
msg - a container for upload request

visit

public void visit(UploadMessage msg)
Process a upload request and send the result back to the client. This may be a very time consuming process and is a blocking call.

Specified by:
visit in interface ArchiveMessageVisitor
Overrides:
visit in class ArchiveMessageHandler
Parameters:
msg - a container for upload request

visit

public void visit(RemoveAndGetFileMessage msg)
Removes an arcfile from the bitarchive and returns the removed file as an remotefile. Answers OK if the file is actually removed. Answers notOk if the file exists with wrong checksum or wrong credentials Doesn't answer if the file doesn't exist. This method always generates a warning when deleting a file. Before the file is removed it is verified that - the file exists in the bitarchive - the file has the correct checksum - the supplied credentials are correct

Specified by:
visit in interface ArchiveMessageVisitor
Overrides:
visit in class ArchiveMessageHandler
Parameters:
msg - a container for remove request

visit

public void visit(BatchMessage msg)
Process a batch job and send the result back to the client.

Specified by:
visit in interface ArchiveMessageVisitor
Overrides:
visit in class ArchiveMessageHandler
Parameters:
msg - a container for batch jobs

visit

public void visit(GetFileMessage msg)
Process a getFile request and send the result back to the client.

Specified by:
visit in interface ArchiveMessageVisitor
Overrides:
visit in class ArchiveMessageHandler
Parameters:
msg - a container for a getfile request

getBitarchiveAppId

public java.lang.String getBitarchiveAppId()
Returns a String that identifies this bit archive application (within the bit archive, i.e. either at KB or SB)

Returns:
String with IP address of this host and, if specified, the HTTP_PORT_NUMBER from settings