Class BitarchiveServer
- java.lang.Object
-
- dk.netarkivet.archive.distribute.ArchiveMessageHandler
-
- dk.netarkivet.archive.bitarchive.distribute.BitarchiveServer
-
- All Implemented Interfaces:
ArchiveMessageVisitor
,CleanupIF
,javax.jms.MessageListener
- Direct Known Subclasses:
AccessBitarchiveServer
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.
-
-
Field Summary
Fields Modifier and Type Field Description Map<String,Thread>
batchProcesses
Map between running batchjob processes and their message id.protected JMSConnection
con
the jms connection.
-
Constructor Summary
Constructors Modifier Constructor Description protected
BitarchiveServer()
The server creates an instance of the bitarchive it provides access to and starts to listen to JMS messages on the incoming jms queue
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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 queuevoid
visit(BatchMessage msg)
Process a batch job and send the result back to the client.void
visit(BatchTerminationMessage msg)
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.
-
-
-
Field Detail
-
con
protected JMSConnection con
the jms connection.
-
-
Constructor Detail
-
BitarchiveServer
protected BitarchiveServer() throws UnknownID, PermissionDenied
The server creates an instance of the bitarchive it provides access to and starts to listen to JMS messages on the incoming jms queueAlso, heartbeats are sent out at regular intervals to the Bitarchive Monitor, to tell that this bitarchive is alive.
- Throws:
UnknownID
- - if there was no heartbeat frequency or temp dir defined in settings or if the bitarchiveid cannot be created.PermissionDenied
- - if the temporary directory or the file directory cannot be written
-
-
Method Detail
-
getInstance
public static BitarchiveServer getInstance() throws ArgumentNotValid, UnknownID
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 queueAlso, 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 settingsArgumentNotValid
- - 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. Closes the bitarchive. Calls cleanup.
-
cleanup
public void cleanup()
Ends the heartbeat sender before next loop.
-
visit
public void visit(GetMessage msg) throws ArgumentNotValid
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 interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- a container for upload request- Throws:
ArgumentNotValid
- If the message is null.
-
visit
public void visit(UploadMessage msg) throws ArgumentNotValid
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 interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- a container for upload request- Throws:
ArgumentNotValid
- If the message is null.
-
visit
public void visit(RemoveAndGetFileMessage msg) throws ArgumentNotValid
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 interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- a container for remove request- Throws:
ArgumentNotValid
- If the RemoveAndGetFileMessage is null.
-
visit
public void visit(BatchMessage msg) throws ArgumentNotValid
Process a batch job and send the result back to the client.- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- a container for batch jobs- Throws:
ArgumentNotValid
- If the BatchMessage is null.
-
visit
public void visit(BatchTerminationMessage msg) throws ArgumentNotValid
- Throws:
ArgumentNotValid
-
visit
public void visit(GetFileMessage msg) throws ArgumentNotValid
Process a getFile request and send the result back to the client.- Specified by:
visit
in interfaceArchiveMessageVisitor
- Overrides:
visit
in classArchiveMessageHandler
- Parameters:
msg
- a container for a getfile request- Throws:
ArgumentNotValid
- If the GetFileMessage is null.
-
getBitarchiveAppId
public String getBitarchiveAppId()
Returns a String that identifies this bit archive application (within the bit archive, i.e. either with id ONE or TWO)- Returns:
- String with IP address of this host and, if specified, the APPLICATION_INSTANCE_ID from settings
-
-