summaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-05-14 11:08:11 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-05-14 11:08:11 +0200
commitfb6b7ae6f14fd63010b5b7e2a968a7bc0bafff2e (patch)
tree774c0d40ba38d104d145cb84362777dfdef7d98d /vespa-maven-plugin
parent81cda304c2c58e381f334a90817dd1ea63a56fe0 (diff)
Handle missing "lastId" items, and sleep between calls
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java37
1 files changed, 26 insertions, 11 deletions
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java
index 503dcdea629..63bb21430ad 100644
--- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java
+++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java
@@ -1,8 +1,10 @@
package ai.vespa.hosted.plugin;
+import ai.vespa.hosted.api.ControllerHttpClient;
import ai.vespa.hosted.api.Deployment;
import ai.vespa.hosted.api.DeploymentLog;
import ai.vespa.hosted.api.DeploymentResult;
+import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.zone.ZoneId;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
@@ -62,18 +64,31 @@ public class DeployMojo extends AbstractVespaMojo {
DeploymentResult result = controller.deploy(deployment, id, zone);
System.out.println(result.message());
- if (follow) {
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss").withZone(ZoneOffset.UTC);
- DeploymentLog log = controller.deploymentLog(id, zone, result.run());
- do {
- for (DeploymentLog.Entry entry : log.entries())
- System.out.printf("[%10s%10s] %s\n",
- entry.level().toUpperCase(),
- formatter.format(entry.at()),
- entry.message());
- log = controller.deploymentLog(id, zone, result.run(), log.last());
+ if (follow) tailLogs(id, zone, result.run());
+ }
+
+ private void tailLogs(ApplicationId id, ZoneId zone, long run) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss").withZone(ZoneOffset.UTC);
+ long last = -1;
+ while (true) {
+ DeploymentLog log = controller.deploymentLog(id, zone, run, last);
+ for (DeploymentLog.Entry entry : log.entries())
+ System.out.printf("%8s%11s %s\n",
+ "[" + entry.level().toUpperCase(),
+ formatter.format(entry.at()) + "]",
+ entry.message());
+ last = log.last().orElse(last);
+
+ if (!log.isActive())
+ break;
+
+ try {
+ Thread.sleep(1000);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ break;
}
- while (log.isActive());
}
}