Search in sources :

Example 6 with PutDocumentMessage

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

the class DocumentProcessingHandlerForkTestCase method assertPutMessages.

private void assertPutMessages(DocumentMessage msg, String route, String... expected) throws InterruptedException {
    msg.getTrace().setLevel(9);
    assertTrue(sendMessage(route, msg));
    String[] actual = new String[expected.length];
    for (int i = 0; i < expected.length; ++i) {
        Message remoteMsg = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
        assertTrue(remoteMsg instanceof PutDocumentMessage);
        remoteMsg.getTrace().trace(1, "remoteServer.ack(" + expected[i] + ")");
        remoteServer.ackMessage(remoteMsg);
        actual[i] = ((PutDocumentMessage) remoteMsg).getDocumentPut().getDocument().getId().toString();
    }
    assertNull(remoteServer.awaitMessage(100, TimeUnit.MILLISECONDS));
    Arrays.sort(expected);
    Arrays.sort(actual);
    assertArrayEquals(expected, actual);
    Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
    assertNotNull(reply);
    assertFalse(reply.hasErrors());
    String trace = reply.getTrace().toString();
    for (String documentId : expected) {
        assertTrue("missing trace for document '" + documentId + "'\n" + trace, trace.contains("remoteServer.ack(" + documentId + ")"));
    }
    if (expected.length == 1) {
        assertFalse("unexpected fork in trace for single document\n" + trace, trace.contains("<fork>"));
    } else {
        assertTrue("missing fork in trace for " + expected.length + " split\n" + trace, trace.contains("<fork>"));
    }
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) Reply(com.yahoo.messagebus.Reply) WriteDocumentReply(com.yahoo.documentapi.messagebus.protocol.WriteDocumentReply)

Example 7 with PutDocumentMessage

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

the class VisitorDataQueueTest method received_put_can_be_polled_via_timeout_getter.

@Test
public void received_put_can_be_polled_via_timeout_getter() throws InterruptedException {
    final VisitorDataQueue queue = new VisitorDataQueue();
    final PutDocumentMessage putMessage = createPutMessage("id:foo:testdoc::foo");
    queue.onMessage(putMessage, createDummyAckToken());
    final VisitorResponse response = queue.getNext(1000);
    assertResponseHasSinglePut(response, putMessage.getDocumentPut());
    // Queue now empty
    assertThat(queue.getNext(), nullValue());
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) Test(org.junit.Test)

Example 8 with PutDocumentMessage

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

the class VisitorDataQueueTest method received_put_can_be_polled_via_non_timeout_getter.

@Test
public void received_put_can_be_polled_via_non_timeout_getter() {
    final VisitorDataQueue queue = new VisitorDataQueue();
    final PutDocumentMessage putMessage = createPutMessage("id:foo:testdoc::foo");
    queue.onMessage(putMessage, createDummyAckToken());
    final VisitorResponse response = queue.getNext();
    assertResponseHasSinglePut(response, putMessage.getDocumentPut());
    // Queue now empty
    assertThat(queue.getNext(), nullValue());
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) Test(org.junit.Test)

Example 9 with PutDocumentMessage

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

the class DocumentOperationMessageV3 method newPutMessage.

static DocumentOperationMessageV3 newPutMessage(VespaXMLFeedReader.Operation op, String operationId) {
    DocumentPut put = new DocumentPut(op.getDocument());
    put.setCondition(op.getCondition());
    Message msg = new PutDocumentMessage(put);
    String id = (operationId == null) ? put.getId().toString() : operationId;
    return new DocumentOperationMessageV3(id, msg);
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) DocumentPut(com.yahoo.document.DocumentPut)

Example 10 with PutDocumentMessage

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

the class Feeder method newPutMessage.

private Tuple2<String, Message> newPutMessage(Operation op, String operationId) {
    DocumentPut put = new DocumentPut(op.getDocument());
    put.setCondition(op.getCondition());
    Message msg = new PutDocumentMessage(put);
    String id = (operationId == null) ? put.getId().toString() : operationId;
    return new Tuple2<>(id, msg);
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) Tuple2(com.yahoo.collections.Tuple2) DocumentPut(com.yahoo.document.DocumentPut) Utf8String(com.yahoo.text.Utf8String)

Aggregations

PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)16 DocumentPut (com.yahoo.document.DocumentPut)5 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)5 Message (com.yahoo.messagebus.Message)5 Test (org.junit.Test)5 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)4 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)3 Reply (com.yahoo.messagebus.Reply)3 Document (com.yahoo.document.Document)2 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)2 Splitter (com.google.common.base.Splitter)1 Tuple2 (com.yahoo.collections.Tuple2)1 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 HttpResponse (com.yahoo.container.jdisc.HttpResponse)1 SessionCache (com.yahoo.container.jdisc.messagebus.SessionCache)1 AccessLog (com.yahoo.container.logging.AccessLog)1 DataType (com.yahoo.document.DataType)1 DocumentOperation (com.yahoo.document.DocumentOperation)1 DocumentType (com.yahoo.document.DocumentType)1 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)1