dk.netarkivet.archive.indexserver.distribute
Class IndexRequestMessage

java.lang.Object
  extended by dk.netarkivet.common.distribute.NetarkivetMessage
      extended by dk.netarkivet.archive.distribute.ArchiveMessage
          extended by dk.netarkivet.archive.indexserver.distribute.IndexRequestMessage
All Implemented Interfaces:
java.io.Serializable

public class IndexRequestMessage
extends ArchiveMessage

Message for requesting and index from the index server, and for giving back the reply.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class dk.netarkivet.common.distribute.NetarkivetMessage
replyOfId
 
Constructor Summary
IndexRequestMessage(RequestType requestType, java.util.Set<java.lang.Long> jobSet)
          Generate an index request message.
 
Method Summary
 void accept(ArchiveMessageVisitor v)
          Calls visit on the visitor.
 java.util.Set<java.lang.Long> getFoundJobs()
          Get the set of jobs for which the index is found.
 java.util.Set<java.lang.Long> getRequestedJobs()
          Get list of requested jobs.
 RequestType getRequestType()
          Get the request type.
 RemoteFile getResultFile()
          The index over the requested jobs.
 java.util.List<RemoteFile> getResultFiles()
          Returns the list of result files for the requested jobs.
 boolean isIndexIsStoredInDirectory()
          If true, this message may carry multiple files that should be stored in a directory.
 void setFoundJobs(java.util.Set<java.lang.Long> foundJobs)
          On reply, set the set of jobs for which an index is found.
 void setResultFile(RemoteFile resultFile)
          On reply, set remote file containing index of requested jobs.
 void setResultFiles(java.util.List<RemoteFile> resultFiles)
          Set several result files making up an index of requested jobs.
 
Methods inherited from class dk.netarkivet.common.distribute.NetarkivetMessage
getErrMsg, getID, getReplyOfId, getReplyTo, getTo, hasBeenSent, isOk, setNotOk, setNotOk, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IndexRequestMessage

public IndexRequestMessage(RequestType requestType,
                           java.util.Set<java.lang.Long> jobSet)
                    throws ArgumentNotValid
Generate an index request message. Receiver is always the index server channel, replyto is always this index client.

Parameters:
requestType - Type of index requested.
jobSet - Jobs for which the index is requested.
Throws:
ArgumentNotValid - if wither argument is null.
Method Detail

accept

public void accept(ArchiveMessageVisitor v)
Calls visit on the visitor.

Specified by:
accept in class ArchiveMessage
Parameters:
v - The visitor of this message.
See Also:
ArchiveMessageVisitor

getRequestedJobs

public java.util.Set<java.lang.Long> getRequestedJobs()
Get list of requested jobs. Should never return null.

Returns:
Set of jobs for which an index is requested.

getRequestType

public RequestType getRequestType()
Get the request type. Should never be null.

Returns:
Type of index requested.

getFoundJobs

public java.util.Set<java.lang.Long> getFoundJobs()
Get the set of jobs for which the index is found. This should always be set on replies, and should always be a subset of the jobs requested. If set of jobs found jobs is the same as the set of requested jobs, the index file should also be present.

Returns:
Set of jobs for which the index is found.

setFoundJobs

public void setFoundJobs(java.util.Set<java.lang.Long> foundJobs)
                  throws ArgumentNotValid
On reply, set the set of jobs for which an index is found. This should always be set on replies, and should always be a subset of the jobs requested. If set of jobs found jobs is the same as the set of requested jobs, the index file should also be set.

Parameters:
foundJobs - The set of jobs for which the index is found
Throws:
ArgumentNotValid - on null argument

getResultFile

public RemoteFile getResultFile()
                         throws IllegalState
The index over the requested jobs. Only set on replies, and only if foundJobs is the same set as requestedJobs.

Returns:
index of requested jobs.
Throws:
IllegalState - if this message is a multiFile message.

getResultFiles

public java.util.List<RemoteFile> getResultFiles()
                                          throws IllegalState
Returns the list of result files for the requested jobs.

Returns:
index of requested jobs in the form of several possibly co-dependent files.
Throws:
IllegalState - if this message is not a multiFile message.

setResultFile

public void setResultFile(RemoteFile resultFile)
                   throws IllegalState,
                          ArgumentNotValid
On reply, set remote file containing index of requested jobs. Should _only_ be set when an index over ALL requested jobs is present.

Parameters:
resultFile - RemoteFile containing index over requested jobs.
Throws:
ArgumentNotValid - on null argument.
IllegalState - if the result file has already been set.

setResultFiles

public void setResultFiles(java.util.List<RemoteFile> resultFiles)
                    throws IllegalState,
                           ArgumentNotValid
Set several result files making up an index of requested jobs. Should _only_ be set when an index over ALL requested jobs is present.

Parameters:
resultFiles - RemoteFiles containing index over requested jobs.
Throws:
ArgumentNotValid - on null argument or null element in list.
IllegalState - if the result files have already been set.

isIndexIsStoredInDirectory

public boolean isIndexIsStoredInDirectory()
If true, this message may carry multiple files that should be stored in a directory.

Returns:
True if more than one file may be transferred with this message.