use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage in project vespa by vespa-engine.
the class DummyReceiver method handleMessage.
public void handleMessage(Message message) {
messageCount++;
if (silentNum == 0) {
System.out.println("Received message " + message + ". Received " + messageCount + " messages so far. In queue size " + queue.size());
if (verbose) {
if (message instanceof PutDocumentMessage) {
System.out.println(" Document:\n" + ((PutDocumentMessage) message).getDocumentPut().getDocument().toXML(" "));
} else if (message instanceof RemoveDocumentMessage) {
System.out.println(" Document id: " + ((RemoveDocumentMessage) message).getDocumentId());
} else if (message instanceof UpdateDocumentMessage) {
System.out.println(" Update:\n " + ((UpdateDocumentMessage) message).getDocumentUpdate().toString());
}
}
} else {
if ((messageCount % silentNum) == 0) {
System.out.println("Received " + messageCount + " messages so far. In queue size " + queue.size());
}
}
EmptyReply reply = new EmptyReply();
message.swapState(reply);
if (!instant) {
try {
executor.execute(new Task(reply));
} catch (RejectedExecutionException e) {
reply.addError(new Error(ErrorCode.SESSION_BUSY, "Session " + name + "/default is busy"));
session.reply(reply);
}
} else {
session.reply(reply);
}
}
use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage 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.documentapi.messagebus.protocol.PutDocumentMessage in project vespa by vespa-engine.
the class DocumentProcessingHandlerForkTestCase method createPutDocumentMessage.
protected PutDocumentMessage createPutDocumentMessage() {
Document document = new Document(getType(), "doc:baz:bar");
document.setFieldValue("blahblah", new StringFieldValue("This is a test."));
return new PutDocumentMessage(new DocumentPut(document));
}
use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage 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());
}
use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage in project vespa by vespa-engine.
the class MessageBusSyncSession method put.
@Override
public void put(DocumentPut documentPut, DocumentProtocol.Priority priority) {
PutDocumentMessage msg = new PutDocumentMessage(documentPut);
msg.setPriority(priority);
syncSendPutDocumentMessage(msg);
}
Aggregations