Class MessageBusSyncSession

  • All Implemented Interfaces:
    MessageBusSession, Session, SyncSession, com.yahoo.messagebus.ReplyHandler

    public class MessageBusSyncSession
    extends java.lang.Object
    implements MessageBusSession, SyncSession, com.yahoo.messagebus.ReplyHandler
    An implementation of the SyncSession interface running over message bus.
    Author:
    Simon Thoresen Hult, bjorncs
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      Destroys this session and frees up any resources it has held.
      com.yahoo.document.Document get​(com.yahoo.document.DocumentId id, DocumentOperationParameters parameters, java.time.Duration timeout)
      Gets a document with timeout.
      com.yahoo.document.Document get​(com.yahoo.document.DocumentId id, java.lang.String fieldSet, DocumentProtocol.Priority pri, java.time.Duration timeout)
      Gets a document with timeout.
      com.yahoo.document.Document get​(com.yahoo.document.DocumentId id, java.time.Duration timeout)
      Gets a document with timeout.
      Response getNext()
      Returns the next response of this session.
      Response getNext​(int timeout)
      Returns the next response of this session.
      java.lang.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.
      void handleReply​(com.yahoo.messagebus.Reply reply)  
      void put​(com.yahoo.document.DocumentPut documentPut)
      Puts a document.
      void put​(com.yahoo.document.DocumentPut documentPut, DocumentOperationParameters parameters)
      Puts a document.
      void put​(com.yahoo.document.DocumentPut documentPut, DocumentProtocol.Priority priority)
      Puts a document.
      boolean remove​(com.yahoo.document.DocumentRemove documentRemove)
      Removes a document if it is present and condition is fulfilled.
      boolean remove​(com.yahoo.document.DocumentRemove documentRemove, DocumentOperationParameters parameters)
      Removes a document if it is present.
      boolean remove​(com.yahoo.document.DocumentRemove documentRemove, DocumentProtocol.Priority pri)
      Removes a document if it is present.
      void setRoute​(java.lang.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.
      com.yahoo.messagebus.Reply syncSend​(com.yahoo.messagebus.Message msg)
      Perform a synchronous sending of a message.
      boolean update​(com.yahoo.document.DocumentUpdate update)
      Updates a document.
      boolean update​(com.yahoo.document.DocumentUpdate update, DocumentOperationParameters parameters)
      Updates a document.
      boolean update​(com.yahoo.document.DocumentUpdate update, DocumentProtocol.Priority pri)
      Updates a document.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • handleReply

        public void handleReply​(com.yahoo.messagebus.Reply reply)
        Specified by:
        handleReply in interface com.yahoo.messagebus.ReplyHandler
      • getNext

        public Response getNext()
        Description copied from interface: Session
        Returns the next response of this session. This method returns immediately.
        Specified by:
        getNext in interface Session
        Returns:
        the next response, or null if no response is ready at this time
      • getNext

        public Response getNext​(int timeout)
        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 interface Session
        Parameters:
        timeout - the max time to wait for a response.
        Returns:
        the next response, or null if no response becomes ready before the timeout expires
      • 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.
        Specified by:
        destroy in interface Session
      • syncSend

        public com.yahoo.messagebus.Reply syncSend​(com.yahoo.messagebus.Message msg)
        Perform a synchronous sending of a message. This method block until the message is successfuly sent and a corresponding reply has been received.
        Parameters:
        msg - The message to send.
        Returns:
        The reply received.
      • put

        public void put​(com.yahoo.document.DocumentPut documentPut)
        Description copied from interface: SyncSession
        Puts a document. When this method returns, the document is safely received. This enables setting condition compared to using Document.
        Specified by:
        put in interface SyncSession
        Parameters:
        documentPut - the DocumentPut operation
      • put

        public void put​(com.yahoo.document.DocumentPut documentPut,
                        DocumentProtocol.Priority priority)
        Description copied from interface: SyncSession
        Puts a document. When this method returns, the document is safely received.
        Specified by:
        put in interface SyncSession
        Parameters:
        documentPut - the DocumentPut operation
        priority - the priority with which to perform this operation
      • put

        public void put​(com.yahoo.document.DocumentPut documentPut,
                        DocumentOperationParameters parameters)
        Description copied from interface: SyncSession
        Puts a document. When this method returns, the document is safely received.
        Specified by:
        put in interface SyncSession
        Parameters:
        documentPut - the DocumentPut operation
        parameters - parameters for the operation
      • get

        public com.yahoo.document.Document get​(com.yahoo.document.DocumentId id,
                                               java.time.Duration timeout)
        Description copied from interface: SyncSession
        Gets a document with timeout.
        Specified by:
        get in interface SyncSession
        Parameters:
        id - the id of the document to get
        timeout - timeout. If timeout is null, an unspecified default will be used
        Returns:
        the document with this id, or null if there is none
      • get

        public com.yahoo.document.Document get​(com.yahoo.document.DocumentId id,
                                               java.lang.String fieldSet,
                                               DocumentProtocol.Priority pri,
                                               java.time.Duration timeout)
        Description copied from interface: SyncSession
        Gets a document with timeout.
        Specified by:
        get in interface SyncSession
        Parameters:
        id - the id of the document to get
        fieldSet - a comma-separated list of fields to retrieve
        pri - the priority with which to perform this operation
        timeout - timeout. If timeout is null, an unspecified default will be used
        Returns:
        the known document having this id, or null if there is no document having this id
      • get

        public com.yahoo.document.Document get​(com.yahoo.document.DocumentId id,
                                               DocumentOperationParameters parameters,
                                               java.time.Duration timeout)
        Description copied from interface: SyncSession
        Gets a document with timeout.
        Specified by:
        get in interface SyncSession
        Parameters:
        id - the id of the document to get
        parameters - parameters for the operation
        timeout - timeout. If timeout is null, an unspecified default will be used
        Returns:
        the known document having this id, or null if there is no document having this id
      • remove

        public boolean remove​(com.yahoo.document.DocumentRemove documentRemove)
        Description copied from interface: SyncSession
        Removes a document if it is present and condition is fulfilled.
        Specified by:
        remove in interface SyncSession
        Parameters:
        documentRemove - document to delete
        Returns:
        true if the document with this id was removed, false otherwise
      • remove

        public boolean remove​(com.yahoo.document.DocumentRemove documentRemove,
                              DocumentProtocol.Priority pri)
        Description copied from interface: SyncSession
        Removes a document if it is present.
        Specified by:
        remove in interface SyncSession
        Parameters:
        documentRemove - document remove operation
        pri - the priority with which to perform this operation
        Returns:
        true if the document with this id was removed, false otherwise.
      • remove

        public boolean remove​(com.yahoo.document.DocumentRemove documentRemove,
                              DocumentOperationParameters parameters)
        Description copied from interface: SyncSession
        Removes a document if it is present.
        Specified by:
        remove in interface SyncSession
        Parameters:
        documentRemove - document remove operation
        parameters - parameters for the operation
        Returns:
        true if the document with this id was removed, false otherwise.
      • update

        public boolean update​(com.yahoo.document.DocumentUpdate update)
        Description copied from interface: SyncSession
        Updates a document.
        Specified by:
        update in interface SyncSession
        Parameters:
        update - the updates to perform
        Returns:
        false if the updates could not be applied as the document does not exist and create-if-non-existent is not set.
      • update

        public boolean update​(com.yahoo.document.DocumentUpdate update,
                              DocumentProtocol.Priority pri)
        Description copied from interface: SyncSession
        Updates a document.
        Specified by:
        update in interface SyncSession
        Parameters:
        update - the updates to perform.
        pri - the priority with which to perform this operation
        Returns:
        false if the updates could not be applied as the document does not exist and create-if-non-existent is not set.
      • update

        public boolean update​(com.yahoo.document.DocumentUpdate update,
                              DocumentOperationParameters parameters)
        Description copied from interface: SyncSession
        Updates a document.
        Specified by:
        update in interface SyncSession
        Parameters:
        update - the updates to perform.
        parameters - parameters for the operation
        Returns:
        false if the updates could not be applied as the document does not exist and create-if-non-existent is not set.
      • getRoute

        public java.lang.String getRoute()
        Description copied from interface: MessageBusSession
        Returns the route to send all messages to when sending through this session.
        Specified by:
        getRoute in interface MessageBusSession
        Returns:
        The route string.
      • setRoute

        public void setRoute​(java.lang.String route)
        Description copied from interface: MessageBusSession
        Sets the route to send all messages to when sending through this session.
        Specified by:
        setRoute in interface MessageBusSession
        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 interface MessageBusSession
        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 interface MessageBusSession
        Parameters:
        traceLevel - The trace level to set.