Search in sources :

Example 1 with DocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.DocumentMessage 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 2 with DocumentMessage

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

the class MbusRequestContext method processingDone.

@Override
public void processingDone(List<Processing> processings) {
    List<DocumentMessage> messages = new ArrayList<>();
    if (messageFactory != null) {
        for (Processing processing : processings) {
            for (DocumentOperation documentOperation : processing.getDocumentOperations()) {
                messages.add(messageFactory.fromDocumentOperation(processing, documentOperation));
            }
        }
    }
    if (log.isLoggable(LogLevel.DEBUG)) {
        log.log(LogLevel.DEBUG, "Forwarding " + messages.size() + " messages from " + processings.size() + " processings.");
    }
    if (messages.isEmpty()) {
        dispatchResponse(Response.Status.OK);
        return;
    }
    long inputSequenceId = requestMsg.getSequenceId();
    ResponseMerger responseHandler = new ResponseMerger(requestMsg, messages.size(), this);
    for (Message message : messages) {
        // See comment for internalNoThrottledSource.
        dispatchRequest(message, (inputSequenceId == message.getSequenceId()) ? getUri().getPath() : "/" + internalNoThrottledSource, responseHandler);
    }
}
Also used : DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) DocumentOperation(com.yahoo.document.DocumentOperation) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) ArrayList(java.util.ArrayList) Processing(com.yahoo.docproc.Processing)

Aggregations

DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)2 Message (com.yahoo.messagebus.Message)2 Processing (com.yahoo.docproc.Processing)1 DocumentOperation (com.yahoo.document.DocumentOperation)1 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)1 WriteDocumentReply (com.yahoo.documentapi.messagebus.protocol.WriteDocumentReply)1 Reply (com.yahoo.messagebus.Reply)1 ArrayList (java.util.ArrayList)1