Search in sources :

Example 16 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class MbusRequestHandler method handleRequest.

@Override
public ContentChannel handleRequest(final Request request, final ResponseHandler handler) {
    if (!(request instanceof MbusRequest)) {
        throw new UnsupportedOperationException("Expected MbusRequest, got " + request.getClass().getName() + ".");
    }
    final Message msg = ((MbusRequest) request).getMessage();
    msg.pushHandler(new RespondingReplyHandler(handler));
    handleMessage(msg);
    return null;
}
Also used : Message(com.yahoo.messagebus.Message)

Example 17 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class DocumentProcessingHandlerAllMessageTypesTestCase method batchDocumentUpdate.

private void batchDocumentUpdate() throws InterruptedException {
    DocumentUpdate doc1 = new DocumentUpdate(getType(), new DocumentId("userdoc:test:12345:multi:1"));
    DocumentUpdate doc2 = new DocumentUpdate(getType(), new DocumentId("userdoc:test:12345:multi:2"));
    Field testField = getType().getField("blahblah");
    doc1.addFieldUpdate(FieldUpdate.createAssign(testField, new StringFieldValue("1 not yet processed")));
    doc2.addFieldUpdate(FieldUpdate.createAssign(testField, new StringFieldValue("2 not yet processed")));
    BatchDocumentUpdateMessage message = new BatchDocumentUpdateMessage(12345);
    message.addUpdate(doc1);
    message.addUpdate(doc2);
    assertTrue(sendMessage(FOOBAR, message));
    Message remote1 = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
    assertTrue(remote1 instanceof UpdateDocumentMessage);
    remoteServer.ackMessage(remote1);
    assertNull(driver.client().awaitReply(100, TimeUnit.MILLISECONDS));
    Message remote2 = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
    assertTrue(remote2 instanceof UpdateDocumentMessage);
    remoteServer.ackMessage(remote2);
    Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
    assertNotNull(reply);
    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) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) BatchDocumentUpdateMessage(com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage) Reply(com.yahoo.messagebus.Reply) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)

Example 18 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class DocumentProcessingHandlerAllMessageTypesTestCase method get.

private void get() throws InterruptedException {
    GetDocumentMessage message = new GetDocumentMessage(new DocumentId("doc:this:is:a:test"), "fieldset?");
    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(GetDocumentMessage.class));
    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) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Reply(com.yahoo.messagebus.Reply)

Example 19 with Message

use of com.yahoo.messagebus.Message 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 20 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class DocumentProcessingHandlerTransformingMessagesTestCase method sendMessageAndGetResult.

private Routable sendMessageAndGetResult(DocumentMessage message) throws InterruptedException {
    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);
    assertFalse(reply.hasErrors());
    return result;
}
Also used : Message(com.yahoo.messagebus.Message) Reply(com.yahoo.messagebus.Reply)

Aggregations

Message (com.yahoo.messagebus.Message)39 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)17 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)15 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)15 Reply (com.yahoo.messagebus.Reply)14 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)13 Test (org.junit.Test)13 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)9 Chain (com.yahoo.component.chain.Chain)7 FeedContext (com.yahoo.feedapi.FeedContext)7 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)7 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)7 Searcher (com.yahoo.search.Searcher)7 Execution (com.yahoo.search.searchchain.Execution)7 ClusterList (com.yahoo.vespaclient.ClusterList)7 Result (com.yahoo.search.Result)6 Utf8String (com.yahoo.text.Utf8String)6 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)5 Tuple2 (com.yahoo.collections.Tuple2)4 EmptyReply (com.yahoo.messagebus.EmptyReply)4