summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-06-24 18:36:08 +0200
committerJon Marius Venstad <venstad@gmail.com>2021-06-24 20:11:49 +0200
commitfa41db1dc35098a28e4ea9b47319cc8977327332 (patch)
treebbdd5885117d44679472fd9eda5035a9412dc1a7
parent3c123c3a50ad792a41411ca30edb6f10964622c5 (diff)
Address reeview :)
-rw-r--r--vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java8
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/ResultException.java25
2 files changed, 30 insertions, 3 deletions
diff --git a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java
index 881194a8490..4398f08024c 100644
--- a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java
+++ b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/CliClient.java
@@ -68,18 +68,20 @@ public class CliClient {
long startNanos = System.nanoTime();
feeder.feedMany(in, new ResultCallback() {
@Override public void onNextResult(Result result, FeedException error) { handleResult(result, error, cliArgs); }
- @Override public void onError(FeedException error) { fatal.set(error); }
+ @Override public void onError(FeedException error) { fatal.set(error); latch.countDown(); }
@Override public void onComplete() { latch.countDown(); }
});
if (cliArgs.showProgress()) {
- new Thread(() -> {
+ Thread progressPrinter = new Thread(() -> {
try {
while ( ! latch.await(10, TimeUnit.SECONDS)) {
synchronized (printMonitor) { printBenchmarkResult(System.nanoTime() - startNanos, feedClient.stats(), systemError);}
}
}
catch (InterruptedException | IOException ignored) { } // doesn't happen
- }).start();
+ });
+ progressPrinter.setDaemon(true);
+ progressPrinter.start();
}
latch.await();
if (cliArgs.benchmarkModeEnabled()) {
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/ResultException.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/ResultException.java
new file mode 100644
index 00000000000..6b235e5e7ab
--- /dev/null
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/ResultException.java
@@ -0,0 +1,25 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.feed.client;
+
+import java.util.Optional;
+
+/**
+ * Signals that the document API in the feed container returned a failure result for a feed operation.
+ *
+ * @author jonmv
+ */
+public class ResultException extends FeedException {
+
+ private final String trace;
+
+ public ResultException(DocumentId documentId, String message, String trace) {
+ super(documentId, message);
+ this.trace = trace;
+ }
+
+ /** Holds the trace, if the failed operation had a {@link OperationParameters#tracelevel(int)} higher than 0. */
+ public Optional<String> getTrace() {
+ return Optional.ofNullable(trace);
+ }
+
+}