public final class IndexRequestServer extends HarvesterMessageHandler implements CleanupIF, IndexRequestServerInterface
This class contains a singleton that handles requesting an index over JMS.
It will ALWAYS reply to such messages, either with the index, a message telling that only a subset is available, and which, or an error message,
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Releases the JMS-connection and resets the singleton.
|
void |
close()
Releases the JMS-connection and resets the singleton.
|
static IndexRequestServer |
getInstance()
Get the unique index request server instance.
|
void |
setHandler(RequestType t,
FileBasedCache<Set<Long>> handler)
Set handler for certain type of index request.
|
void |
start()
Look for stored messages to be preprocessed, and start processing those.
|
void |
visit(IndexRequestMessage irMsg)
Given a request for an index over a set of job ids, use a cache to try to create the index, Then reply result.
|
public static IndexRequestServer getInstance()
public void setHandler(RequestType t, FileBasedCache<Set<Long>> handler)
setHandler
in interface IndexRequestServerInterface
t
- The type of index requestedhandler
- The handler that should handle this request.public void visit(IndexRequestMessage irMsg) throws ArgumentNotValid
If for any reason not all requested jobs can be indexed, return the subset. The client can then retry with this subset, in order to get index of that subset.
Values read from the message in order to handle this: - Type of index requested - will use the index cache of this type - Set of job IDs - which jobs to generate index for
Values written to message before replying: - The subset indexed - may be the entire set. ALWAYS set unless reply !OK - File with index - ONLY if subset is entire set, the index requested.
This method should ALWAYS reply. May reply with not OK message if: - Message received was not OK - Request type is null or unknown in message - Set of job ids is null in message - Cache generation throws exception
visit
in interface HarvesterMessageVisitor
visit
in class HarvesterMessageHandler
irMsg
- A message requesting an index.ArgumentNotValid
- on null parameterpublic void close()
close
in interface IndexRequestServerInterface
public void cleanup()
public void start()
start
in interface IndexRequestServerInterface
Copyright © 2005–2015 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.