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(" "));
}
}
}
Aggregations