use of com.yahoo.messagebus.EmptyReply 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.EmptyReply 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.EmptyReply in project vespa by vespa-engine.
the class BenchmarkProgressPrinterTest method testSimple.
public void testSimple() {
ByteArrayOutputStream output = new ByteArrayOutputStream();
DummyTimer timer = new DummyTimer();
timer.ms = 0;
BenchmarkProgressPrinter printer = new BenchmarkProgressPrinter(timer, new PrintStream(output));
RouteMetricSet metrics = new RouteMetricSet("foobar", printer);
{
EmptyReply reply = new EmptyReply();
reply.setMessage(PutDocumentMessage.createEmpty().setTimeReceived(1));
metrics.addReply(reply);
}
timer.ms = 1200;
{
EmptyReply reply = new EmptyReply();
reply.setMessage(PutDocumentMessage.createEmpty().setTimeReceived(2));
metrics.addReply(reply);
}
{
EmptyReply reply = new EmptyReply();
reply.setMessage(UpdateDocumentMessage.createEmpty().setTimeReceived(3));
metrics.addReply(reply);
}
timer.ms = 2400;
{
EmptyReply reply = new EmptyReply();
reply.setMessage(UpdateDocumentMessage.createEmpty().setTimeReceived(4));
reply.addError(new com.yahoo.messagebus.Error(32, "foo"));
metrics.addReply(reply);
}
timer.ms = 62000;
{
EmptyReply reply = new EmptyReply();
reply.setMessage(UpdateDocumentMessage.createEmpty().setTimeReceived(5));
reply.addError(new com.yahoo.messagebus.Error(64, "bar"));
metrics.addReply(reply);
}
metrics.done();
String val = output.toString().split("\n")[1];
String correctPattern = "62000,\\s*3,\\s*2,\\s*\\d+,\\s*\\d+,\\s*\\d+$";
assertTrue("Value '" + val + "' does not match pattern '" + correctPattern + "'", val.matches(correctPattern));
}
use of com.yahoo.messagebus.EmptyReply in project vespa by vespa-engine.
the class StoragePolicyTestEnvironment method replyOk.
protected void replyOk(RoutingNode target) {
target.handleReply(new EmptyReply());
Reply reply = frame.getReceptor().getReply(60);
assertNotNull(reply);
assertFalse(reply.hasErrors());
if (debug)
System.err.println("OK: " + reply.getTrace());
}
use of com.yahoo.messagebus.EmptyReply in project vespa by vespa-engine.
the class StoragePolicyTestEnvironment method replyError.
protected void replyError(RoutingNode target, com.yahoo.messagebus.Error error) {
EmptyReply reply = new EmptyReply();
reply.addError(error);
target.handleReply(reply);
assertTrue(reply == frame.getReceptor().getReply(60));
assertTrue(reply.hasErrors());
if (debug)
System.err.println("ERROR: " + reply.getTrace());
}
Aggregations