aboutsummaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-03-03 15:33:27 +0100
committerJon Marius Venstad <venstad@gmail.com>2020-03-03 15:33:27 +0100
commit1bf286b9b95ea1f3705436ca551a29fa4ecb6fc3 (patch)
tree6b693c81cab2a8f210ad87f3d346957717979fac /hosted-api
parent1676c7f550a2b36265951f0f22086b8f0b563863 (diff)
Allow aggregating deployment log in client
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java7
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentLog.java9
2 files changed, 13 insertions, 3 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 376719aed1d..79c11cf86de 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
@@ -156,11 +156,12 @@ public abstract class ControllerHttpClient {
public DeploymentLog followDeploymentUntilDone(ApplicationId id, ZoneId zone, long run,
Consumer<DeploymentLog.Entry> out) {
long last = -1;
- DeploymentLog log;
+ DeploymentLog log = null;
while (true) {
- log = deploymentLog(id, zone, run, last);
- for (DeploymentLog.Entry entry : log.entries())
+ DeploymentLog update = deploymentLog(id, zone, run, last);
+ for (DeploymentLog.Entry entry : update.entries())
out.accept(entry);
+ log = (log == null ? update : log.updatedWith(update));
last = log.last().orElse(last);
if ( ! log.isActive())
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentLog.java b/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentLog.java
index 177c72107e0..9eae9a33cff 100644
--- a/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentLog.java
+++ b/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentLog.java
@@ -4,6 +4,7 @@ package ai.vespa.hosted.api;
import java.time.Instant;
import java.util.List;
import java.util.OptionalLong;
+import java.util.stream.Stream;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toUnmodifiableList;
@@ -27,6 +28,14 @@ public class DeploymentLog {
this.last = last;
}
+ /** Returns this log updated with the content of the other. */
+ public DeploymentLog updatedWith(DeploymentLog other) {
+ return new DeploymentLog(Stream.concat(entries.stream(), other.entries.stream()).collect(toUnmodifiableList()),
+ other.active,
+ other.status,
+ other.last);
+ }
+
public List<Entry> entries() {
return entries;
}