use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.
the class SimpleFeederTest method requireThatAsyncFailuresThrowInMainThread.
@Test
public void requireThatAsyncFailuresThrowInMainThread() throws Throwable {
TestDriver driver = new TestDriver(new FeederParams(), "<vespafeed><document documenttype='simple' documentid='doc:scheme:0'/></vespafeed>", new MessageHandler() {
@Override
public void handleMessage(Message msg) {
Reply reply = new EmptyReply();
reply.swapState(msg);
reply.addError(new Error(ErrorCode.APP_FATAL_ERROR + 6, "foo"));
reply.addError(new Error(ErrorCode.APP_FATAL_ERROR + 9, "bar"));
reply.popHandler().handleReply(reply);
}
});
try {
driver.run();
fail();
} catch (IOException e) {
assertMatches("com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage@.+\n" + "\\[UNKNOWN\\(250006\\) @ .+\\]: foo\n" + "\\[UNKNOWN\\(250009\\) @ .+\\]: bar\n", e.getMessage());
}
assertTrue(driver.close());
}
use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.
the class MbusRequestHandlerTestCase method requireThatHandlerCanRespondInSameThread.
@Test
public void requireThatHandlerCanRespondInSameThread() throws Exception {
TestDriver driver = newTestDriver(SameThreadReplier.INSTANCE);
Response response = dispatchMessage(driver, new SimpleMessage("msg")).get(60, TimeUnit.SECONDS);
assertTrue(response instanceof MbusResponse);
assertEquals(Response.Status.OK, response.getStatus());
Reply reply = ((MbusResponse) response).getReply();
assertTrue(reply instanceof EmptyReply);
assertFalse(reply.hasErrors());
assertTrue(driver.close());
}
use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.
the class BucketStatsRetriever method sendMessage.
private <T extends Reply> T sendMessage(DocumentMessage msg, Class<T> expectedReply) throws BucketStatsException {
setRoute(msg, route);
Reply reply = session.syncSend(msg);
return validateReply(reply, expectedReply);
}
use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.
the class DummySessionFactory method sendReply.
public void sendReply(Message m, Error error) {
MyContext ctxt = (MyContext) m.getContext();
Reply r = new EmptyReply();
r.setMessage(m);
r.setContext(ctxt.oldContext);
if (error != null) {
r.addError(error);
}
ctxt.handler.handleReply(r);
}
use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.
the class DocumentProtocol method merge.
/**
* This method implements the common way to merge document replies for whatever routing policy. In case of an error
* in any of the replies, it will prepare an EmptyReply() and add all errors to it. If there are no errors, this
* method will use the first reply in the list and transfer whatever feed answers might exist in the replies to it.
*
* @param ctx The context whose children to merge.
* @param mask The indexes of the children to skip.
*/
public static void merge(RoutingContext ctx, Set<Integer> mask) {
List<Reply> replies = new LinkedList<>();
for (RoutingNodeIterator it = ctx.getChildIterator(); it.isValid(); it.next()) {
Reply ref = it.getReplyRef();
replies.add(ref);
}
Tuple2<Integer, Reply> tuple = merge(replies, mask);
if (tuple.first != null) {
ctx.getChildIterator().skip(tuple.first).removeReply();
}
ctx.setReply(tuple.second);
}
Aggregations