Class MessageBusAsyncSession
- java.lang.Object
-
- com.yahoo.documentapi.messagebus.MessageBusAsyncSession
-
- All Implemented Interfaces:
AsyncSession
,MessageBusSession
,Session
public class MessageBusAsyncSession extends Object implements MessageBusSession, AsyncSession
An access session which wraps a messagebus source session sending document messages. The sessions are multithread safe.- Author:
- bratseth, Einar Rosenvinge
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
destroy()
Destroys this session and frees up any resources it has held.Result
get(com.yahoo.document.DocumentId id)
Gets a document.Result
get(com.yahoo.document.DocumentId id, boolean headersOnly, DocumentProtocol.Priority pri)
Deprecated.Result
get(com.yahoo.document.DocumentId id, DocumentOperationParameters parameters)
Gets a document.double
getCurrentWindowSize()
Returns the current send window size of the session.Response
getNext()
Returns the next response of this session.Response
getNext(int timeoutMilliseconds)
Returns the next response of this session.String
getRoute()
Returns the route to send all messages to when sending through this session.int
getTraceLevel()
Returns the trace level used when sending messages through this session.Result
put(com.yahoo.document.Document document)
Puts a document.Result
put(com.yahoo.document.DocumentPut documentPut, DocumentOperationParameters parameters)
Puts a document, with optional conditions on the operation.Result
remove(com.yahoo.document.DocumentId id)
Removes a document if it is present.Result
remove(com.yahoo.document.DocumentRemove remove, DocumentOperationParameters parameters)
Removes a document if it is present.Result
send(com.yahoo.messagebus.Message msg)
A convenience method for assigning the internal trace level and route string to a message before sending it through the internal mbus session object.void
setRoute(String route)
Sets the route to send all messages to when sending through this session.void
setTraceLevel(int traceLevel)
Sets the trace level used when sending messages through this session.Result
update(com.yahoo.document.DocumentUpdate update)
Updates a document.Result
update(com.yahoo.document.DocumentUpdate update, DocumentOperationParameters parameters)
Updates a document.
-
-
-
Method Detail
-
put
public Result put(com.yahoo.document.Document document)
Description copied from interface:AsyncSession
Puts a document. This method returns immediately.
If this result is a success, this call will cause one or more
DocumentResponse
objects to appear within the timeout time of this session. The response returned later will either be a success, or contain the document submitted here. If it was not a success, this method has no further effects.- Specified by:
put
in interfaceAsyncSession
- Parameters:
document
- the Document to put- Returns:
- the synchronous result of this operation
-
put
public Result put(com.yahoo.document.DocumentPut documentPut, DocumentOperationParameters parameters)
Description copied from interface:AsyncSession
Puts a document, with optional conditions on the operation. This method returns immediately.
If this result is a success, this call will cause one or more
DocumentResponse
objects to appear within the timeout time of this session. The response returned later will either be a success, or contain the document submitted here. If it was not a success, this method has no further effects.- Specified by:
put
in interfaceAsyncSession
- Parameters:
documentPut
- the DocumentPut to performparameters
- parameters for the operation- Returns:
- the synchronous result of this operation
-
get
public Result get(com.yahoo.document.DocumentId id)
Description copied from interface:AsyncSession
Gets a document. This method returns immediately.
If this result is a success, this call will cause one or more
DocumentResponse
objects to appear within the timeout time of this session. The response returned later will contain the requested document if it is a success. If it was not a success, this method has no further effects.- Specified by:
get
in interfaceAsyncSession
- Parameters:
id
- the id of the document to get- Returns:
- the synchronous result of this operation
-
get
@Deprecated public Result get(com.yahoo.document.DocumentId id, boolean headersOnly, DocumentProtocol.Priority pri)
Deprecated.Description copied from interface:AsyncSession
Gets a document. This method returns immediately.
If this result is a success, this call will cause one or more
DocumentResponse
objects to appear within the timeout time of this session. The response returned later will contain the requested document if it is a success. If it was not a success, this method has no further effects.- Specified by:
get
in interfaceAsyncSession
- Parameters:
id
- the id of the document to getpri
- The priority with which to perform this operation.- Returns:
- the synchronous result of this operation
-
get
public Result get(com.yahoo.document.DocumentId id, DocumentOperationParameters parameters)
Description copied from interface:AsyncSession
Gets a document. This method returns immediately.
If this result is a success, this call will cause one or more
DocumentResponse
objects to appear within the timeout time of this session. The response returned later will contain the requested document if it is a success. If it was not a success, this method has no further effects.- Specified by:
get
in interfaceAsyncSession
- Parameters:
id
- the id of the document to getparameters
- parameters for the operation- Returns:
- the synchronous result of this operation
-
remove
public Result remove(com.yahoo.document.DocumentId id)
Description copied from interface:AsyncSession
Removes a document if it is present. This method returns immediately.
If this result is a success, this call will cause one or more
RemoveResponse
objects to appear within the timeout time of this session. The response returned later will either be a success, or contain the document id submitted here. If it was not a success, this method has no further effects.- Specified by:
remove
in interfaceAsyncSession
- Parameters:
id
- the id of the document to remove- Returns:
- the synchronous result of this operation
-
remove
public Result remove(com.yahoo.document.DocumentRemove remove, DocumentOperationParameters parameters)
Description copied from interface:AsyncSession
Removes a document if it is present. This method returns immediately.
If this result is a success, this call will cause one or more
DocumentIdResponse
objects to appear within the timeout time of this session. The response returned later will either be a success, or contain the document id submitted here. If it was not a success, this method has no further effects.- Specified by:
remove
in interfaceAsyncSession
- Parameters:
remove
- the document remove operationparameters
- parameters for the operation- Returns:
- the synchronous result of this operation
-
update
public Result update(com.yahoo.document.DocumentUpdate update)
Description copied from interface:AsyncSession
Updates a document. This method returns immediately.
If this result is a success, this call will cause one or more
DocumentUpdateResponse
within the timeout time of this session. The returned response returned later will either be a success or contain the update submitted here. If it was not a success, this method has no further effects.- Specified by:
update
in interfaceAsyncSession
- Parameters:
update
- the updates to perform- Returns:
- the synchronous result of this operation
-
update
public Result update(com.yahoo.document.DocumentUpdate update, DocumentOperationParameters parameters)
Description copied from interface:AsyncSession
Updates a document. This method returns immediately.
If this result is a success, this call will cause one or more
DocumentUpdateResponse
within the timeout time of this session. The returned response returned later will either be a success or contain the update submitted here. If it was not a success, this method has no further effects.- Specified by:
update
in interfaceAsyncSession
- Parameters:
update
- the updates to performparameters
- parameters for the operation- Returns:
- the synchronous result of this operation
-
send
public Result send(com.yahoo.messagebus.Message msg)
A convenience method for assigning the internal trace level and route string to a message before sending it through the internal mbus session object.- Parameters:
msg
- the message to send.- Returns:
- the document api result object.
-
getNext
public Response getNext()
Description copied from interface:Session
Returns the next response of this session. This method returns immediately.
-
getNext
public Response getNext(int timeoutMilliseconds) throws InterruptedException
Description copied from interface:Session
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 interfaceSession
- Parameters:
timeoutMilliseconds
- the max time to wait for a response.- Returns:
- the next response, or null if no response becomes ready before the timeout expires
- Throws:
InterruptedException
- if this thread is interrupted while waiting
-
destroy
public void destroy()
Description copied from interface:Session
Destroys this session and frees up any resources it has held. Making further calls on a destroyed session causes a runtime exception.
-
getRoute
public String getRoute()
Description copied from interface:MessageBusSession
Returns the route to send all messages to when sending through this session.- Specified by:
getRoute
in interfaceMessageBusSession
- Returns:
- The route string.
-
setRoute
public void setRoute(String route)
Description copied from interface:MessageBusSession
Sets the route to send all messages to when sending through this session.- Specified by:
setRoute
in interfaceMessageBusSession
- Parameters:
route
- The route string.
-
getTraceLevel
public int getTraceLevel()
Description copied from interface:MessageBusSession
Returns the trace level used when sending messages through this session.- Specified by:
getTraceLevel
in interfaceMessageBusSession
- Returns:
- The trace level.
-
setTraceLevel
public void setTraceLevel(int traceLevel)
Description copied from interface:MessageBusSession
Sets the trace level used when sending messages through this session.- Specified by:
setTraceLevel
in interfaceMessageBusSession
- Parameters:
traceLevel
- The trace level to set.
-
getCurrentWindowSize
public double getCurrentWindowSize()
Description copied from interface:AsyncSession
Returns the current send window size of the session.- Specified by:
getCurrentWindowSize
in interfaceAsyncSession
- Returns:
- Returns the window size.
-
-