use of com.yahoo.vespa.http.client.SimpleLoggerResultCallback in project vespa by vespa-engine.
the class Runner method main.
public static void main(String[] args) throws IOException, InterruptedException {
final CommandLineArguments commandLineArgs = CommandLineArguments.build(args);
if (commandLineArgs == null) {
return;
}
FormatInputStream formatInputStream = new FormatInputStream(System.in, Optional.ofNullable(commandLineArgs.getFile()), commandLineArgs.getAddRootElementToXml());
int intervalOfLogging = commandLineArgs.getVerbose() ? commandLineArgs.getWhenVerboseEnabledPrintMessageForEveryXDocuments() : Integer.MAX_VALUE;
final AtomicInteger numSent = new AtomicInteger(0);
final SimpleLoggerResultCallback callback = new SimpleLoggerResultCallback(numSent, intervalOfLogging);
final FeedClient feedClient = FeedClientFactory.create(commandLineArgs.createSessionParams(formatInputStream.getFormat() == FormatInputStream.Format.JSON), callback);
long sendTotalTimeMs = send(feedClient, formatInputStream.getInputStream(), formatInputStream.getFormat() == FormatInputStream.Format.JSON, numSent, commandLineArgs.getVerbose());
if (commandLineArgs.getVerbose()) {
System.err.println(feedClient.getStatsAsJson());
double fileSizeMb = ((double) new File(commandLineArgs.getFile()).length()) / 1024.0 / 1024.0;
double transferTimeSec = ((double) sendTotalTimeMs) / 1000.0;
System.err.println("Sent " + fileSizeMb + " MB in " + transferTimeSec + " seconds.");
System.err.println("Speed: " + ((fileSizeMb / transferTimeSec) * 8.0) + " Mbits/sec, + HTTP overhead " + "(not taking compression into account)");
if (transferTimeSec > 0) {
System.err.printf("Docs/sec %.3f%n\n", numSent.get() / transferTimeSec);
}
}
callback.printProgress();
}
Aggregations