Search in sources :

Example 6 with DocumentAccessException

use of com.yahoo.documentapi.DocumentAccessException in project vespa by vespa-engine.

the class MessageBusSyncSession method get.

@Override
public Document get(DocumentId id, String fieldSet, DocumentProtocol.Priority pri, Duration timeout) {
    GetDocumentMessage msg = new GetDocumentMessage(id, fieldSet);
    msg.setPriority(pri);
    Reply reply = syncSend(msg, timeout != null ? timeout : defaultTimeout);
    if (reply.hasErrors()) {
        throw new DocumentAccessException(MessageBusAsyncSession.getErrorMessage(reply));
    }
    if (reply.getType() != DocumentProtocol.REPLY_GETDOCUMENT) {
        throw new DocumentAccessException("Received unknown response: " + reply);
    }
    GetDocumentReply docReply = ((GetDocumentReply) reply);
    Document doc = docReply.getDocument();
    if (doc != null) {
        doc.setLastModified(docReply.getLastModified());
    }
    return doc;
}
Also used : GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Reply(com.yahoo.messagebus.Reply) RemoveDocumentReply(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentReply) UpdateDocumentReply(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentReply) GetDocumentReply(com.yahoo.documentapi.messagebus.protocol.GetDocumentReply) Document(com.yahoo.document.Document) GetDocumentReply(com.yahoo.documentapi.messagebus.protocol.GetDocumentReply) DocumentAccessException(com.yahoo.documentapi.DocumentAccessException)

Aggregations

DocumentAccessException (com.yahoo.documentapi.DocumentAccessException)6 SyncSession (com.yahoo.documentapi.SyncSession)3 MessageBusSyncSession (com.yahoo.documentapi.messagebus.MessageBusSyncSession)3 Instant (java.time.Instant)3 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)2 RemoveDocumentReply (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentReply)2 UpdateDocumentReply (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentReply)2 Reply (com.yahoo.messagebus.Reply)2 Document (com.yahoo.document.Document)1 DocumentId (com.yahoo.document.DocumentId)1 DocumentPut (com.yahoo.document.DocumentPut)1 DocumentRemove (com.yahoo.document.DocumentRemove)1 TestAndSetCondition (com.yahoo.document.TestAndSetCondition)1 Result (com.yahoo.documentapi.Result)1 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)1 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)1