Search in sources :

Example 6 with EmptyReply

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());
}
Also used : Response(com.yahoo.jdisc.Response) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) TestDriver(com.yahoo.jdisc.test.TestDriver) EmptyReply(com.yahoo.messagebus.EmptyReply) Test(org.junit.Test)

Example 7 with EmptyReply

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);
}
Also used : Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) EmptyReply(com.yahoo.messagebus.EmptyReply)

Example 8 with EmptyReply

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));
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RouteMetricSet(com.yahoo.clientmetrics.RouteMetricSet) EmptyReply(com.yahoo.messagebus.EmptyReply)

Example 9 with EmptyReply

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());
}
Also used : Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) EmptyReply(com.yahoo.messagebus.EmptyReply)

Example 10 with EmptyReply

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());
}
Also used : EmptyReply(com.yahoo.messagebus.EmptyReply)

Aggregations

EmptyReply (com.yahoo.messagebus.EmptyReply)21 Reply (com.yahoo.messagebus.Reply)15 Error (com.yahoo.messagebus.Error)8 Test (org.junit.Test)3 RouteMetricSet (com.yahoo.clientmetrics.RouteMetricSet)2 Version (com.yahoo.component.Version)2 Response (com.yahoo.jdisc.Response)2 TestDriver (com.yahoo.jdisc.test.TestDriver)2 Message (com.yahoo.messagebus.Message)2 Hop (com.yahoo.messagebus.routing.Hop)2 Route (com.yahoo.messagebus.routing.Route)2 RoutingNode (com.yahoo.messagebus.routing.RoutingNode)2 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)2 Utf8Array (com.yahoo.text.Utf8Array)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintStream (java.io.PrintStream)2 CompressionType (com.yahoo.compress.CompressionType)1 DocumentIgnoredReply (com.yahoo.documentapi.messagebus.protocol.DocumentIgnoredReply)1 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)1 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)1