Search in sources :

Example 6 with UpdateDocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage in project vespa by vespa-engine.

the class DocumentProcessingHandlerAllMessageTypesTestCase method update.

private void update() throws InterruptedException {
    DocumentUpdate documentUpdate = new DocumentUpdate(getType(), "doc:baz:foo");
    UpdateDocumentMessage message = new UpdateDocumentMessage(documentUpdate);
    assertTrue(sendMessage(FOOBAR, message));
    Message result = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
    assertNotNull(result);
    remoteServer.ackMessage(result);
    Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
    assertNotNull(reply);
    assertThat(result, instanceOf(UpdateDocumentMessage.class));
    UpdateDocumentMessage outputMsg = (UpdateDocumentMessage) result;
    assertThat(outputMsg.getDocumentUpdate().getId().toString(), is("doc:baz:foo"));
    assertFalse(reply.hasErrors());
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) BatchDocumentUpdateMessage(com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage) Reply(com.yahoo.messagebus.Reply) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)

Example 7 with UpdateDocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage in project vespa by vespa-engine.

the class MessageBusSyncSession method update.

@Override
public boolean update(DocumentUpdate update, DocumentProtocol.Priority pri) {
    UpdateDocumentMessage msg = new UpdateDocumentMessage(update);
    msg.setPriority(pri);
    Reply reply = syncSend(msg);
    if (reply.hasErrors()) {
        throw new DocumentAccessException(MessageBusAsyncSession.getErrorMessage(reply), reply.getErrorCodes());
    }
    if (reply.getType() != DocumentProtocol.REPLY_UPDATEDOCUMENT) {
        throw new DocumentAccessException("Received unknown response: " + reply);
    }
    return ((UpdateDocumentReply) reply).wasFound();
}
Also used : UpdateDocumentReply(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentReply) 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) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) DocumentAccessException(com.yahoo.documentapi.DocumentAccessException)

Aggregations

UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)7 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)5 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)5 Message (com.yahoo.messagebus.Message)4 Reply (com.yahoo.messagebus.Reply)3 DocumentUpdate (com.yahoo.document.DocumentUpdate)2 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)2 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)2 Tuple2 (com.yahoo.collections.Tuple2)1 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)1 DocumentAccessException (com.yahoo.documentapi.DocumentAccessException)1 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)1 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)1 RemoveDocumentReply (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentReply)1 UpdateDocumentReply (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentReply)1 EmptyReply (com.yahoo.messagebus.EmptyReply)1 Error (com.yahoo.messagebus.Error)1 Utf8String (com.yahoo.text.Utf8String)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1