Search in sources :

Example 1 with Trace

use of com.yahoo.messagebus.Trace in project vespa by vespa-engine.

the class DocumentRetriever method printReply.

private void printReply(Reply reply) {
    Trace trace = reply.getTrace();
    if (!trace.getRoot().isEmpty()) {
        System.out.println(trace);
    }
    if (reply.hasErrors()) {
        System.err.print("Request failed: ");
        for (int i = 0; i < reply.getNumErrors(); i++) {
            System.err.printf("\n  %s", reply.getError(i));
        }
        System.err.println();
        return;
    }
    if (!(reply instanceof GetDocumentReply)) {
        System.err.printf("Unexpected reply %s: '%s'\n", reply.getType(), reply.toString());
        return;
    }
    GetDocumentReply documentReply = (GetDocumentReply) reply;
    Document document = documentReply.getDocument();
    if (document == null) {
        System.out.println("Document not found.");
        return;
    }
    if (params.showDocSize) {
        System.out.printf("Document size: %d bytes.\n", document.getSerializedSize());
    }
    if (params.printIdsOnly) {
        System.out.println(document.getId());
    } else {
        if (params.jsonOutput) {
            System.out.print(Utf8.toString(JsonWriter.toByteArray(document)));
        } else {
            System.out.print(document.toXML("  "));
        }
    }
}
Also used : Trace(com.yahoo.messagebus.Trace) Document(com.yahoo.document.Document) GetDocumentReply(com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)

Aggregations

Document (com.yahoo.document.Document)1 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)1 Trace (com.yahoo.messagebus.Trace)1