Package com.yahoo.documentapi
Class VisitorDataQueue
- java.lang.Object
-
- com.yahoo.documentapi.VisitorDataHandler
-
- com.yahoo.documentapi.VisitorDataQueue
-
public class VisitorDataQueue extends VisitorDataHandler
A visitor data handler that queues up documents in visitor responses and implements thegetNext
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
Constructors Constructor Description VisitorDataQueue()
Creates a new visitor data queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VisitorResponse
getNext()
Returns the next response of this session.VisitorResponse
getNext(int timeoutMilliseconds)
Returns the next response of this session.void
onMessage(com.yahoo.messagebus.Message m, AckToken token)
Called when a data message is received.void
reset()
Called before the visitor starts.-
Methods inherited from class com.yahoo.documentapi.VisitorDataHandler
ack, onDone, setSession
-
-
-
-
Method Detail
-
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
public void onMessage(com.yahoo.messagebus.Message m, AckToken token)
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
public VisitorResponse 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
public VisitorResponse getNext(int timeoutMilliseconds) throws InterruptedException
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
-
-