Search in sources :

Example 6 with RouteMetricSet

use of com.yahoo.clientmetrics.RouteMetricSet in project vespa by vespa-engine.

the class ProgressPrinterTest method testSimple.

public void testSimple() {
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    DummyTimer timer = new DummyTimer();
    timer.ms = 0;
    ProgressPrinter printer = new ProgressPrinter(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;
    {
        DocumentIgnoredReply reply = new DocumentIgnoredReply();
        reply.setMessage(PutDocumentMessage.createEmpty().setTimeReceived(0));
        metrics.addReply(reply);
    }
    {
        EmptyReply reply = new EmptyReply();
        reply.setMessage(UpdateDocumentMessage.createEmpty().setTimeReceived(5));
        reply.addError(new com.yahoo.messagebus.Error(32, "foo"));
        metrics.addReply(reply);
    }
    timer.ms = 62000;
    {
        EmptyReply reply = new EmptyReply();
        reply.setMessage(UpdateDocumentMessage.createEmpty().setTimeReceived(6));
        reply.addError(new com.yahoo.messagebus.Error(64, "bar"));
        metrics.addReply(reply);
    }
    String val = output.toString().replaceAll("latency\\(min, max, avg\\): .*", "latency(min, max, avg): 0, 0, 0");
    String correct = "\rSuccessfully sent 2 messages so far" + "\rSuccessfully sent 3 messages so far" + "\n\n" + "Messages sent to vespa (route foobar) :\n" + "---------------------------------------\n" + "PutDocument:\tok: 2 msgs/sec: 0.03 failed: 0 ignored: 1 latency(min, max, avg): 0, 0, 0\n" + "UpdateDocument:\tok: 1 msgs/sec: 0.02 failed: 2 ignored: 0 latency(min, max, avg): 0, 0, 0\n";
    assertEquals(correct, val);
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RouteMetricSet(com.yahoo.clientmetrics.RouteMetricSet) EmptyReply(com.yahoo.messagebus.EmptyReply) DocumentIgnoredReply(com.yahoo.documentapi.messagebus.protocol.DocumentIgnoredReply)

Aggregations

RouteMetricSet (com.yahoo.clientmetrics.RouteMetricSet)6 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)3 SingleSender (com.yahoo.feedapi.SingleSender)3 EmptyReply (com.yahoo.messagebus.EmptyReply)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintStream (java.io.PrintStream)2 MessageTypeMetricSet (com.yahoo.clientmetrics.MessageTypeMetricSet)1 EmptyResponse (com.yahoo.container.jdisc.EmptyResponse)1 DocumentId (com.yahoo.document.DocumentId)1 DocumentIgnoredReply (com.yahoo.documentapi.messagebus.protocol.DocumentIgnoredReply)1 RemoveLocationMessage (com.yahoo.documentapi.messagebus.protocol.RemoveLocationMessage)1 DocprocMessageProcessor (com.yahoo.feedapi.DocprocMessageProcessor)1 Feeder (com.yahoo.feedapi.Feeder)1 JsonFeeder (com.yahoo.feedapi.JsonFeeder)1 XMLFeeder (com.yahoo.feedapi.XMLFeeder)1 Metric (com.yahoo.metrics.Metric)1 MetricSet (com.yahoo.metrics.MetricSet)1 SumMetric (com.yahoo.metrics.SumMetric)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1