Package com.yahoo.documentapi
Class VisitorDataQueue
java.lang.Object
com.yahoo.documentapi.VisitorDataHandler
com.yahoo.documentapi.VisitorDataQueue
A visitor data handler that queues up documents in visitor responses and
implements the
getNext
methods, thus implementing the polling
API defined in VisitorDataHandler.
Visitor responses should be polled for with the
getNext
methods and need to be acked when processed for
visiting not to halt. The class is thread safe.
- Author:
- HÃ¥kon Humberset, vekterli
-
Field Summary
Fields inherited from class com.yahoo.documentapi.VisitorDataHandler
session
-
Constructor Summary
-
Method Summary
Methods inherited from class com.yahoo.documentapi.VisitorDataHandler
ack, onDone, setSession
-
Constructor Details
-
VisitorDataQueue
public VisitorDataQueue()Creates a new visitor data queue.
-
-
Method Details
-
reset
public void reset()Description copied from class:VisitorDataHandler
Called before the visitor starts. Override this method if you need to reset local data. Remember to call the superclass' method as well.- Overrides:
reset
in classVisitorDataHandler
-
onMessage
Description copied from class:VisitorDataHandler
Called when a data message is received. IMPORTANT: May be called concurrently from multiple threads. Any internal state mutations MUST be done in a thread-safe manner.- Specified by:
onMessage
in classVisitorDataHandler
- Parameters:
m
- The message receivedtoken
- A token to reply with when finished processing the message.
-
getNext
Description copied from class:VisitorDataHandler
Returns the next response of this session. This method returns immediately.- Overrides:
getNext
in classVisitorDataHandler
- Returns:
- the next response, or null if no response is ready at this time
-
getNext
Description copied from class:VisitorDataHandler
Returns the next response of this session. This will block until a response is ready or the given timeout is reached.- Overrides:
getNext
in classVisitorDataHandler
- 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:
InterruptedException
- if this thread is interrupted while waiting
-