use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentRetriever method retrieveDocuments.
public void retrieveDocuments() throws DocumentRetrieverException {
boolean first = true;
String route = params.cluster.isEmpty() ? params.route : resolveClusterRoute(params.cluster);
LoadType loadType = params.loadTypeName.isEmpty() ? null : resolveLoadType(params.loadTypeName);
MessageBusParams messageBusParams = createMessageBusParams(params.configId, params.timeout, route);
documentAccess = documentAccessFactory.createDocumentAccess(messageBusParams);
session = documentAccess.createSyncSession(new SyncParameters.Builder().build());
int trace = params.traceLevel;
if (trace > 0) {
session.setTraceLevel(trace);
}
Iterator<String> iter = params.documentIds;
if (params.jsonOutput && !params.printIdsOnly) {
System.out.println('[');
}
while (iter.hasNext()) {
if (params.jsonOutput && !params.printIdsOnly) {
if (!first) {
System.out.println(',');
} else {
first = false;
}
}
String docid = iter.next();
Message msg = createDocumentRequest(docid, loadType);
Reply reply = session.syncSend(msg);
printReply(reply);
}
if (params.jsonOutput && !params.printIdsOnly) {
System.out.println(']');
}
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentProcessingHandlerAllMessageTypesTestCase method put.
private void put() throws InterruptedException {
Document document = new Document(getType(), "doc:baz:foo");
document.setFieldValue("blahblah", new StringFieldValue("This is a test."));
PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(document));
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(PutDocumentMessage.class));
PutDocumentMessage outputMsg = (PutDocumentMessage) result;
assertThat(((StringFieldValue) outputMsg.getDocumentPut().getDocument().getFieldValue("blahblah")).getString(), is("THIS IS A TEST."));
assertFalse(reply.hasErrors());
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentProcessingHandlerAllMessageTypesTestCase method remove.
private void remove() throws InterruptedException {
RemoveDocumentMessage message = new RemoveDocumentMessage(new DocumentId("doc:12345:6789"));
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(RemoveDocumentMessage.class));
RemoveDocumentMessage outputMsg = (RemoveDocumentMessage) result;
assertThat(outputMsg.getDocumentId().toString(), is("doc:12345:6789"));
assertFalse(reply.hasErrors());
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentProcessingHandlerAllMessageTypesTestCase method update.
private void update() throws InterruptedException {
DocumentUpdate documentUpdate = new DocumentUpdate(getType(), "doc:baz:foo");
UpdateDocumentMessage message = new UpdateDocumentMessage(documentUpdate);
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(UpdateDocumentMessage.class));
UpdateDocumentMessage outputMsg = (UpdateDocumentMessage) result;
assertThat(outputMsg.getDocumentUpdate().getId().toString(), is("doc:baz:foo"));
assertFalse(reply.hasErrors());
}
use of com.yahoo.messagebus.Message in project vespa by vespa-engine.
the class DocumentProcessingHandlerBasicTestCase method testPut.
@Test
public void testPut() throws InterruptedException {
Document document = new Document(getType(), "doc:yalla:balla");
document.setFieldValue("blahblah", new StringFieldValue("This is a test."));
PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(document));
assertTrue(sendMessage("foobar", message));
Message msg = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
assertNotNull(msg);
remoteServer.ackMessage(msg);
Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
assertNotNull(reply);
assertThat((msg instanceof PutDocumentMessage), is(true));
PutDocumentMessage put = (PutDocumentMessage) msg;
Document outDoc = put.getDocumentPut().getDocument();
assertThat(document, equalTo(outDoc));
assertFalse(reply.hasErrors());
}
Aggregations