Class IndexRequestClient
- java.lang.Object
-
- dk.netarkivet.harvester.indexserver.FileBasedCache<Set<T>>
-
- dk.netarkivet.harvester.indexserver.MultiFileBasedCache<Long>
-
- dk.netarkivet.harvester.indexserver.distribute.IndexRequestClient
-
- All Implemented Interfaces:
JobIndexCache
public class IndexRequestClient extends MultiFileBasedCache<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.
-
-
Field Summary
Fields Modifier and Type Field Description static String
INDEXREQUEST_TIMEOUT
settings.common.indexClient.indexRequestTimeout:
Setting for the amount of time, in milliseconds, we should wait for replies when issuing a call to generate an index over some jobs.static String
INDEXREQUEST_USE_LOCAL_FTPSERVER
settings.common.indexClient.useLocalFtpServer:
Setting for using the ftpserver assigned to the client instead of the one assigned to the indexserver.-
Fields inherited from class dk.netarkivet.harvester.indexserver.FileBasedCache
cacheDir
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Set<Long>
cacheData(Set<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.void
requestIndex(Set<Long> jobSet, Long harvestId)
Method to request an Index without having the result sent right away.protected boolean
useLocalFtpserver()
Check if we should use local ftpserver or not, provided you are using FTPRemoteFile as theCommonSettings.REMOTE_FILE_CLASS
.-
Methods inherited from class dk.netarkivet.harvester.indexserver.MultiFileBasedCache
getCacheFile
-
Methods inherited from class dk.netarkivet.harvester.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
-
-
-
-
Field Detail
-
INDEXREQUEST_TIMEOUT
public static final String INDEXREQUEST_TIMEOUT
settings.common.indexClient.indexRequestTimeout:
Setting for the amount of time, in milliseconds, we should wait for replies when issuing a call to generate an index over some jobs.- See Also:
- Constant Field Values
-
INDEXREQUEST_USE_LOCAL_FTPSERVER
public static final String INDEXREQUEST_USE_LOCAL_FTPSERVER
settings.common.indexClient.useLocalFtpServer:
Setting for using the ftpserver assigned to the client instead of the one assigned to the indexserver. Set to false by default.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static IndexRequestClient getInstance(RequestType type) throws ArgumentNotValid
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 Set<Long> cacheData(Set<Long> jobSet) throws IOFailure, IllegalState, ArgumentNotValid
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<Long> of found jobs, and the side effect of caching the index, is done using this communication with the server. The resulting files will be unzipped into the cache dir.This method should not be called directly! Instead call cache() or getIndex().
- Specified by:
cacheData
in classFileBasedCache<Set<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(T)
,FileBasedCache.getIndex(T)
-
getIndexTimeout
protected long getIndexTimeout()
How long should we wait for index replies?- Returns:
- Index timeout value in milliseconds.
-
useLocalFtpserver
protected boolean useLocalFtpserver()
Check if we should use local ftpserver or not, provided you are using FTPRemoteFile as theCommonSettings.REMOTE_FILE_CLASS
. This always returns false, whenCommonSettings.REMOTE_FILE_CLASS
is notFTPRemoteFile
.- Returns:
- true, if we should use the local ftpserver when retrieving data from the indexserver, false, if the indexserver should decide for us.
-
requestIndex
public void requestIndex(Set<Long> jobSet, Long harvestId) throws IOFailure, IllegalState, ArgumentNotValid
Method to request an Index without having the result sent right away.- Specified by:
requestIndex
in interfaceJobIndexCache
- Parameters:
jobSet
- The set of job IDs.harvestId
- The ID of the harvest requesting this index.- Throws:
IOFailure
- On trouble in communication or invalid reply types.IllegalState
- if message is not OK.ArgumentNotValid
- if the jobSet is null.
-
-