Package com.yahoo.documentapi.messagebus
Class MessageBusVisitorSession
java.lang.Object
com.yahoo.documentapi.messagebus.MessageBusVisitorSession
- All Implemented Interfaces:
VisitorControlSession
,VisitorSession
A visitor session for tracking progress for and potentially receiving data from a visitor using a MessageBus source and destination session. The source session is used to initiate visiting by sending create visitor messages to storage and the destination session is used for receiving progress. If the visitor is not set up to send data to a remote destination, data will also be received through the destination session.
Create the visitor session by calling the
DocumentAccess.createVisitorSession
method.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static class
static class
static class
Message bus implementations of interfacesstatic class
static class
static interface
Abstract away notion of destination session into a generic Receiver interface to allow easy mocking.static interface
static interface
Abstract away notion of source session into a generic Sender interface to allow easy mocking.static interface
static enum
class
static class
static class
-
Constructor Summary
ConstructorDescriptionMessageBusVisitorSession
(VisitorParameters visitorParameters, MessageBusVisitorSession.AsyncTaskExecutor taskExecutor, MessageBusVisitorSession.SenderFactory senderFactory, MessageBusVisitorSession.ReceiverFactory receiverFactory, com.yahoo.messagebus.routing.RoutingTable routingTable) MessageBusVisitorSession
(VisitorParameters visitorParameters, MessageBusVisitorSession.AsyncTaskExecutor taskExecutor, MessageBusVisitorSession.SenderFactory senderFactory, MessageBusVisitorSession.ReceiverFactory receiverFactory, com.yahoo.messagebus.routing.RoutingTable routingTable, MessageBusVisitorSession.Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Aborts the session.void
Acknowledges a response previously retrieved by thegetNext
method.static MessageBusVisitorSession
createForMessageBus
(com.yahoo.messagebus.MessageBus mbus, ScheduledExecutorService scheduledExecutorService, VisitorParameters params) void
destroy()
Destroys this session and frees up any resources it has held.getNext()
Returns the next response of this session.getNext
(int timeoutMilliseconds) Returns the next response of this session.Retrieves the last progress token gotten for this visitor.com.yahoo.messagebus.Trace
getTrace()
Returns the tracing information so far about the visitor.boolean
For unit test purposes only, not to be used by any external parties.boolean
isDone()
Checks if visiting is done.void
start()
boolean
waitUntilDone
(long timeoutMs) Waits until visiting is done, or the given timeout (in ms) expires.
-
Constructor Details
-
MessageBusVisitorSession
public MessageBusVisitorSession(VisitorParameters visitorParameters, MessageBusVisitorSession.AsyncTaskExecutor taskExecutor, MessageBusVisitorSession.SenderFactory senderFactory, MessageBusVisitorSession.ReceiverFactory receiverFactory, com.yahoo.messagebus.routing.RoutingTable routingTable) throws com.yahoo.document.select.parser.ParseException - Throws:
com.yahoo.document.select.parser.ParseException
-
MessageBusVisitorSession
public MessageBusVisitorSession(VisitorParameters visitorParameters, MessageBusVisitorSession.AsyncTaskExecutor taskExecutor, MessageBusVisitorSession.SenderFactory senderFactory, MessageBusVisitorSession.ReceiverFactory receiverFactory, com.yahoo.messagebus.routing.RoutingTable routingTable, MessageBusVisitorSession.Clock clock) throws com.yahoo.document.select.parser.ParseException - Throws:
com.yahoo.document.select.parser.ParseException
-
-
Method Details
-
createForMessageBus
public static MessageBusVisitorSession createForMessageBus(com.yahoo.messagebus.MessageBus mbus, ScheduledExecutorService scheduledExecutorService, VisitorParameters params) throws com.yahoo.document.select.parser.ParseException - Throws:
com.yahoo.document.select.parser.ParseException
-
start
public void start() -
getSessionName
-
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
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
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:
InterruptedException
- If an interrupt signal was received while waiting.
-
ack
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
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
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:
InterruptedException
- if this thread is interrupted while waiting
-
isDestroying
public boolean isDestroying()For unit test purposes only, not to be used by any external parties.- Returns:
- true if destroy() has been--or is being--invoked.
-
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
-