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