aboutsummaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-02-29 11:42:35 +0100
committerJon Marius Venstad <venstad@gmail.com>2020-02-29 11:42:35 +0100
commit852ca81bd49811a82274aa01ffd40d0c2dc5f773 (patch)
treec72bcada6e6cd36ec79b5ee29ffbc2b831c8cebb /hosted-api
parent9ac4f3d18e1dbb11678b8d61fa50c9ad1cdf61d2 (diff)
Move deployment tailing logic to client
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java
index f1486ae7117..6fba083e607 100644
--- a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java
+++ b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java
@@ -37,6 +37,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.OptionalLong;
import java.util.concurrent.Callable;
+import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Stream;
@@ -145,6 +146,31 @@ public abstract class ControllerHttpClient {
GET)));
}
+ /** Follows the given deployment job until it is done, or this thread is interrupted, at which point the current status is returned. */
+ public DeploymentLog followDeploymentUntilDone(ApplicationId id, ZoneId zone, long run,
+ Consumer<DeploymentLog.Entry> out) {
+ long last = -1;
+ DeploymentLog log;
+ while (true) {
+ log = deploymentLog(id, zone, run, last);
+ for (DeploymentLog.Entry entry : log.entries())
+ out.accept(entry);
+ last = log.last().orElse(last);
+
+ if ( ! log.isActive())
+ break;
+
+ try {
+ Thread.sleep(1000);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ break;
+ }
+ }
+ return log;
+ }
+
/** Returns the sorted list of log entries from the deployment job of the given ids. */
public DeploymentLog deploymentLog(ApplicationId id, ZoneId zone, long run) {
return deploymentLog(id, zone, run, -1);