Skip to content

Commit

Permalink
Update programmatic use of feed client to reflect changes to statisti…
Browse files Browse the repository at this point in the history
…cs interface
  • Loading branch information
bjorncs committed Jan 29, 2025
1 parent 19963cc commit 5271117
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ static void printJsonReport(Duration duration, OperationStats stats, String load
generator.writeStartObject();
generator.writeNumberField("feeder.runtime", duration.toMillis());
generator.writeNumberField("feeder.okcount", stats.successes());
generator.writeNumberField("feeder.errorcount", stats.exceptions() + stats.responsesByCode().entrySet().stream().filter(entry -> entry.getKey() != 200).map(Entry::getValue).reduce(0L, Long::sum));
generator.writeNumberField("feeder.errorcount", stats.exceptions() + stats.statsByCode().entrySet().stream()
.filter(entry -> entry.getKey() != 200)
.map(e -> e.getValue().count())
.reduce(0L, Long::sum));
generator.writeNumberField("feeder.exceptions", stats.exceptions());
generator.writeNumberField("feeder.bytessent", stats.bytesSent());
generator.writeNumberField("feeder.bytesreceived", stats.bytesReceived());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ public static void main(String[] args) throws IOException {
FeedClient client = createFeedClient();
AtomicReference<OperationStats> stats = new AtomicReference<>();
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.schedule(() -> { stats.set(client.stats()); },
warmupSeconds(), TimeUnit.SECONDS);
executor.schedule(() -> { stats.set(client.stats().since(stats.get())); executor.shutdown(); },
executor.schedule(client::resetStats, warmupSeconds(), TimeUnit.SECONDS);
executor.schedule(() -> { stats.set(client.stats()); executor.shutdown(); },
warmupSeconds() + benchmarkSeconds(), TimeUnit.SECONDS);
executor.scheduleAtFixedRate(() -> { System.err.println(client.stats()); },
1, 1, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void main(String[] args) throws IOException {
AtomicReference<OperationStats> stats = new AtomicReference<>();
AtomicLong startNanos = new AtomicLong();
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.schedule(() -> { stats.set(client.stats()); startNanos.set(System.nanoTime()); },
executor.schedule(() -> { client.resetStats(); startNanos.set(System.nanoTime()); },
warmupSeconds(), TimeUnit.SECONDS);
executor.scheduleAtFixedRate(() -> { System.err.println(client.stats()); },
1, 1, TimeUnit.SECONDS);
Expand All @@ -55,7 +55,7 @@ public static void main(String[] args) throws IOException {
JsonFeeder feeder = JsonFeeder.builder(client).withRoute(route()).build()) {
feeder.feedMany(in);
}
printJsonReport(Duration.ofNanos(System.nanoTime() - startNanos.get()), client.stats().since(stats.get()), "vespa-json-feeder");
printJsonReport(Duration.ofNanos(System.nanoTime() - startNanos.get()), client.stats(), "vespa-json-feeder");
executor.shutdown();
}

Expand Down

0 comments on commit 5271117

Please sign in to comment.