Class TestIndexRequestServer
- java.lang.Object
-
- dk.netarkivet.harvester.distribute.HarvesterMessageHandler
-
- dk.netarkivet.harvester.indexserver.distribute.TestIndexRequestServer
-
- All Implemented Interfaces:
CleanupIF
,HarvesterMessageVisitor
,IndexRequestServerInterface
,javax.jms.MessageListener
public final class TestIndexRequestServer extends HarvesterMessageHandler implements CleanupIF, IndexRequestServerInterface
Index request server singleton.This class contains a singleton that handles requesting an index over JMS.
This has two modes. 1) Given a file with a list of jobIDs, it will always return the same lucene index based on the list of job identifiers in the file regardless of what kind of index the client is requesting. 2) if setting "settings.harvester.indexserver.alwaysSetIsIndexReadyToFalse" is true it will always return the IndexRequestMessage with isindexready set to false.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALWAYS_SET_ISINDEX_READY_TO_FALSE
settings.archive.indexserver.alwaysSetIsIndexReadyToFalse: The default: false.static String
JOBS_FOR_TESTINDEX
settings.harvester.indexserver.fileContainingJobsForTestindex: The file containing the list of jobids that the test index uses as data.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Releases the JMS-connection and resets the singleton.void
close()
Releases the JMS-connection and resets the singleton.static TestIndexRequestServer
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.
-
-
-
Field Detail
-
JOBS_FOR_TESTINDEX
public static String JOBS_FOR_TESTINDEX
settings.harvester.indexserver.fileContainingJobsForTestindex: The file containing the list of jobids that the test index uses as data. The default name of the file is "jobids.txt"
-
ALWAYS_SET_ISINDEX_READY_TO_FALSE
public static String ALWAYS_SET_ISINDEX_READY_TO_FALSE
settings.archive.indexserver.alwaysSetIsIndexReadyToFalse: The default: false. If set to true, the IndexRequestMessage returned has always isindexready = false.
-
-
Method Detail
-
getInstance
public static TestIndexRequestServer getInstance()
Get the unique index request server instance.- Returns:
- The index request server.
-
setHandler
public void setHandler(RequestType t, FileBasedCache<Set<Long>> handler)
Set handler for certain type of index request. If called more than once, new handler overwrites old one.- Specified by:
setHandler
in interfaceIndexRequestServerInterface
- Parameters:
t
- The type of index requestedhandler
- The handler that should handle this request.
-
visit
public void visit(IndexRequestMessage irMsg) throws ArgumentNotValid
Given a request for an index over a set of job ids, use a cache to try to create the index, Then reply result.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
- Specified by:
visit
in interfaceHarvesterMessageVisitor
- Overrides:
visit
in classHarvesterMessageHandler
- Parameters:
irMsg
- A message requesting an index.- Throws:
ArgumentNotValid
- on null parameter
-
close
public void close()
Releases the JMS-connection and resets the singleton.- Specified by:
close
in interfaceIndexRequestServerInterface
-
cleanup
public void cleanup()
Releases the JMS-connection and resets the singleton.
-
start
public void start()
Look for stored messages to be preprocessed, and start processing those. And start the separate thread that decides if we should listen for index-requests.- Specified by:
start
in interfaceIndexRequestServerInterface
-
-