Interface SyncSession

  • All Superinterfaces:
    Session
    All Known Implementing Classes:
    LocalSyncSession, MessageBusSyncSession

    public interface SyncSession
    extends Session
    A session for synchronous access to a document repository. This class provides simple document access where throughput is not a concern.
    Author:
    Simon Thoresen Hult, bjorncs
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default com.yahoo.document.Document get​(com.yahoo.document.DocumentId id)
      Gets a document.
      default com.yahoo.document.Document get​(com.yahoo.document.DocumentId id, java.lang.String fieldSet, DocumentProtocol.Priority priority)
      Gets a document with an unspecified timeout
      com.yahoo.document.Document get​(com.yahoo.document.DocumentId id, java.lang.String fieldSet, DocumentProtocol.Priority priority, 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.
      void put​(com.yahoo.document.DocumentPut documentPut)
      Puts a document.
      default 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, DocumentProtocol.Priority priority)
      Removes a document if it is present.
      boolean update​(com.yahoo.document.DocumentUpdate update)
      Updates a document.
      boolean update​(com.yahoo.document.DocumentUpdate update, DocumentProtocol.Priority priority)
      Updates a document.
    • Method Detail

      • put

        void put​(com.yahoo.document.DocumentPut documentPut)
        Puts a document. When this method returns, the document is safely received. This enables setting condition compared to using Document.
        Parameters:
        documentPut - The DocumentPut operation
      • put

        default void put​(com.yahoo.document.DocumentPut documentPut,
                         DocumentProtocol.Priority priority)
        Puts a document. When this method returns, the document is safely received.
        Parameters:
        documentPut - The DocumentPut operation
        priority - The priority with which to perform this operation.
      • get

        default com.yahoo.document.Document get​(com.yahoo.document.DocumentId id)
        Gets a document.
        Parameters:
        id - The id of the document to get.
        Returns:
        The known document having this id, or null if there is no document having this id.
        Throws:
        java.lang.UnsupportedOperationException - Thrown if this access does not support retrieving.
      • get

        default com.yahoo.document.Document get​(com.yahoo.document.DocumentId id,
                                                java.lang.String fieldSet,
                                                DocumentProtocol.Priority priority)
        Gets a document with an unspecified timeout
        Parameters:
        id - the id of the document to get
        fieldSet - a comma-separated list of fields to retrieve
        priority - the priority with which to perform this operation
        Returns:
        the document with this id, or null if there is none
        Throws:
        java.lang.UnsupportedOperationException - thrown if this does not support retrieving
      • get

        com.yahoo.document.Document get​(com.yahoo.document.DocumentId id,
                                        java.time.Duration timeout)
        Gets a document with timeout.
        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
        Throws:
        java.lang.UnsupportedOperationException - thrown if this access does not support retrieving
        DocumentAccessException - on any messagebus error, including timeout (ErrorCode.TIMEOUT).
      • get

        com.yahoo.document.Document get​(com.yahoo.document.DocumentId id,
                                        java.lang.String fieldSet,
                                        DocumentProtocol.Priority priority,
                                        java.time.Duration timeout)
        Gets a document with timeout.
        Parameters:
        id - The id of the document to get.
        fieldSet - A comma-separated list of fields to retrieve
        priority - 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.
        Throws:
        java.lang.UnsupportedOperationException - Thrown if this access does not support retrieving.
        DocumentAccessException - on any messagebus error, including timeout (ErrorCode.TIMEOUT).
      • remove

        boolean remove​(com.yahoo.document.DocumentRemove documentRemove)

        Removes a document if it is present and condition is fulfilled.

        Parameters:
        documentRemove - document to delete
        Returns:
        true if the document with this id was removed, false otherwise.
      • remove

        boolean remove​(com.yahoo.document.DocumentRemove documentRemove,
                       DocumentProtocol.Priority priority)
        Removes a document if it is present.
        Parameters:
        documentRemove - Document remove operation
        priority - The priority with which to perform this operation.
        Returns:
        true If the document with this id was removed, false otherwise.
        Throws:
        java.lang.UnsupportedOperationException - Thrown if this access does not support removal.
      • update

        boolean update​(com.yahoo.document.DocumentUpdate update)
        Updates a document.
        Parameters:
        update - The updates to perform.
        Returns:
        True, if the document was found and updated.
        Throws:
        java.lang.UnsupportedOperationException - Thrown if this access does not support update.
      • update

        boolean update​(com.yahoo.document.DocumentUpdate update,
                       DocumentProtocol.Priority priority)
        Updates a document.
        Parameters:
        update - The updates to perform.
        priority - The priority with which to perform this operation.
        Returns:
        True, if the document was found and updated.
        Throws:
        java.lang.UnsupportedOperationException - Thrown if this access does not support update.