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>"));
}
}
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);
}
}
Aggregations