Package com.yahoo.documentapi.local
Class LocalVisitorSession
- java.lang.Object
-
- com.yahoo.documentapi.local.LocalVisitorSession
-
- All Implemented Interfaces:
VisitorControlSession
,VisitorSession
public class LocalVisitorSession extends java.lang.Object implements VisitorSession
Local visitor session that copies and iterates through all items in the local document access. Each document must be ack'ed for the session to be done visiting. Only document puts are sent by this session, and this is done from a separate thread.- Author:
- jonmv
-
-
Constructor Summary
Constructors Constructor Description LocalVisitorSession(LocalDocumentAccess access, VisitorParameters parameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Aborts the session.void
ack(AckToken token)
Acknowledges a response previously retrieved by thegetNext
method.void
destroy()
Destroys this session and frees up any resources it has held.VisitorResponse
getNext()
Returns the next response of this session.VisitorResponse
getNext(int timeoutMilliseconds)
Returns the next response of this session.ProgressToken
getProgress()
Retrieves the last progress token gotten for this visitor.com.yahoo.messagebus.Trace
getTrace()
Returns the tracing information so far about the visitor.boolean
isDone()
Checks if visiting is done.boolean
waitUntilDone(long timeoutMs)
Waits until visiting is done, or the given timeout (in ms) expires.
-
-
-
Constructor Detail
-
LocalVisitorSession
public LocalVisitorSession(LocalDocumentAccess access, VisitorParameters parameters) throws com.yahoo.document.select.parser.ParseException
- Throws:
com.yahoo.document.select.parser.ParseException
-
-
Method Detail
-
isDone
public boolean isDone()
Description copied from interface:VisitorSession
Checks if visiting is done.- Specified by:
isDone
in interfaceVisitorSession
- Returns:
- True if visiting is done (either by error or success).
-
getProgress
public ProgressToken getProgress()
Description copied from interface:VisitorSession
Retrieves the last progress token gotten for this visitor.- Specified by:
getProgress
in interfaceVisitorSession
- Returns:
- The progress token.
-
getTrace
public com.yahoo.messagebus.Trace getTrace()
Description copied from interface:VisitorSession
Returns the tracing information so far about the visitor.- Specified by:
getTrace
in interfaceVisitorSession
- Returns:
- Returns the trace.
-
waitUntilDone
public boolean waitUntilDone(long timeoutMs) throws java.lang.InterruptedException
Description copied from interface:VisitorSession
Waits until visiting is done, or the given timeout (in ms) expires. Will wait forever if timeout is 0.- Specified by:
waitUntilDone
in interfaceVisitorSession
- Parameters:
timeoutMs
- The maximum amount of milliseconds to wait.- Returns:
- True if visiting is done (either by error or success).
- Throws:
java.lang.InterruptedException
- If an interrupt signal was received while waiting.
-
ack
public void ack(AckToken token)
Description copied from interface:VisitorControlSession
Acknowledges a response previously retrieved by thegetNext
method.- Specified by:
ack
in interfaceVisitorControlSession
- Parameters:
token
- The ack token. You must get this from the visitor response returned by thegetNext
method.
-
abort
public void abort()
Description copied from interface:VisitorControlSession
Aborts the session.- Specified by:
abort
in interfaceVisitorControlSession
-
getNext
public VisitorResponse getNext()
Description copied from interface:VisitorControlSession
Returns the next response of this session. This method returns immediately.- Specified by:
getNext
in interfaceVisitorControlSession
- Returns:
- the next response, or null if no response is ready at this time
-
getNext
public VisitorResponse getNext(int timeoutMilliseconds) throws java.lang.InterruptedException
Description copied from interface:VisitorControlSession
Returns the next response of this session. This will block until a response is ready or until the given timeout is reached- Specified by:
getNext
in interfaceVisitorControlSession
- Parameters:
timeoutMilliseconds
- the max time to wait for a response. If the number is 0, this will block without any timeout limit- Returns:
- the next response, or null if no response becomes ready before the timeout expires
- Throws:
java.lang.InterruptedException
- if this thread is interrupted while waiting
-
destroy
public void destroy()
Description copied from interface:VisitorControlSession
Destroys this session and frees up any resources it has held.- Specified by:
destroy
in interfaceVisitorControlSession
-
-