Search in sources :

Example 1 with SimpleLoggerResultCallback

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();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleLoggerResultCallback(com.yahoo.vespa.http.client.SimpleLoggerResultCallback) FeedClient(com.yahoo.vespa.http.client.FeedClient) File(java.io.File)

Aggregations

FeedClient (com.yahoo.vespa.http.client.FeedClient)1 SimpleLoggerResultCallback (com.yahoo.vespa.http.client.SimpleLoggerResultCallback)1 File (java.io.File)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1