dk.netarkivet.archive.indexserver.distribute
Class IndexRequestClient

java.lang.Object
  extended by dk.netarkivet.archive.indexserver.FileBasedCache<java.util.Set<T>>
      extended by dk.netarkivet.archive.indexserver.MultiFileBasedCache<java.lang.Long>
          extended by dk.netarkivet.archive.indexserver.distribute.IndexRequestClient
All Implemented Interfaces:
JobIndexCache

public class IndexRequestClient
extends MultiFileBasedCache<java.lang.Long>
implements JobIndexCache

Client for index request server. Allows to request an index of some type over a list of jobs. Factory method will return the index request client of the type wished.


Method Summary
protected  java.util.Set<java.lang.Long> cacheData(java.util.Set<java.lang.Long> jobSet)
          This method makes sure the actual caching of underlying data is done using the index server.
protected  long getIndexTimeout()
          How long should we wait for index replies?
static IndexRequestClient getInstance(RequestType type)
          Factory method returning an IndexRequestClient for the given type of index cache.
 
Methods inherited from class dk.netarkivet.archive.indexserver.MultiFileBasedCache
getCacheFile
 
Methods inherited from class dk.netarkivet.archive.indexserver.FileBasedCache
cache, get, getCacheDir, getIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dk.netarkivet.common.distribute.indexserver.JobIndexCache
getIndex
 

Method Detail

getInstance

public static IndexRequestClient getInstance(RequestType type)
Factory method returning an IndexRequestClient for the given type of index cache.

Parameters:
type - The type of this cache.
Returns:
The singleton instance dedicated to this type of index requests.
Throws:
ArgumentNotValid - if type is null.

cacheData

protected java.util.Set<java.lang.Long> cacheData(java.util.Set<java.lang.Long> jobSet)
This method makes sure the actual caching of underlying data is done using the index server. It will convert calls into an IndexRequestMessage which is sent to the server. The Set of found jobs, and the side effect of caching the index, is done using this communication with the server. This method should not be called directly! Instead call cache() or getIndex().

Specified by:
cacheData in class FileBasedCache<java.util.Set<java.lang.Long>>
Parameters:
jobSet - The set of job IDs.
Returns:
The set of found job IDs.
Throws:
ArgumentNotValid - on null argument; or on wrong parameters in replied message.
IOFailure - on trouble in communication or invalid reply types.
IllegalState - if message is not OK.
See Also:
FileBasedCache.cache(I), FileBasedCache.getIndex(I)

getIndexTimeout

protected long getIndexTimeout()
How long should we wait for index replies?

Returns:
Index timeout value in milliseconds.