summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2018-07-03 15:34:44 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2018-07-03 15:34:44 +0200
commit98feb2edfde11e8964af1d7902a4d14f436fdb34 (patch)
tree0d2a2f86dcc54046e4628938f8a34fe63d1be6e6 /controller-server
parent45180ef9556ceea8df516dc239033f064128f46c (diff)
Store one object per deployment job step
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java43
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java27
2 files changed, 34 insertions, 36 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
index 9366a678e88..056dcba2cd5 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java
@@ -16,6 +16,8 @@ import com.yahoo.vespa.hosted.controller.application.JobStatus;
import com.yahoo.vespa.hosted.controller.application.SourceRevision;
import com.yahoo.vespa.hosted.controller.persistence.CuratorDb;
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -67,29 +69,32 @@ public class JobController {
}
}
- /** Returns the details currently logged for the given run. */
- public RunDetails details(RunId id) {
- return new RunDetails(logs.getDeploymentLog(id), logs.getConvergenceLog(id), logs.getTestLog(id));
- }
-
- /** Appends the given string to the currently stored deployment logs for the given run. */
- public void logDeployment(RunId id, String appendage) {
- try (Lock __ = curator.lock(id.application(), id.type())) {
- logs.setDeploymentLog(id, logs.getDeploymentLog(id).concat(appendage));
- }
- }
-
- /** Appends the given string to the currently stored convergence logs for the given run. */
- public void logConvergence(RunId id, String appendage) {
- try (Lock __ = curator.lock(id.application(), id.type())) {
- logs.setConvergenceLog(id, logs.getConvergenceLog(id).concat(appendage));
+ /** Returns the details currently logged for the given run, if known. */
+ public Optional<RunDetails> details(RunId id) {
+ RunStatus run = runs(id.application(), id.type()).get(id);
+ if (run == null)
+ return Optional.empty();
+
+ Map<Step, byte[]> details = new HashMap<>();
+ for (Step step : run.steps().keySet()) {
+ byte[] log = logs.getLog(id, step.name());
+ if (log.length > 0)
+ details.put(step, log);
}
+ return Optional.of(new RunDetails(details));
}
- /** Appends the given string to the currently stored test logs for the given run. */
- public void logTest(RunId id, String appendage) {
+ /** Appends the given log bytes to the currently stored bytes for the given run and step. */
+ public void log(RunId id, Step step, byte[] log) {
try (Lock __ = curator.lock(id.application(), id.type())) {
- logs.setTestLog(id, logs.getTestLog(id).concat(appendage));
+ byte[] stored = logs.getLog(id, step.name());
+ if (stored.length > 0) {
+ byte[] addition = log;
+ log = new byte[stored.length + addition.length];
+ System.arraycopy(stored, 0, log, 0, stored.length);
+ System.arraycopy(addition, 0, log, stored.length, addition.length);
+ }
+ logs.setLog(id, step.name(), log);
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java
index 98969bd4508..ebe2b920d0a 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/RunDetails.java
@@ -1,5 +1,10 @@
package com.yahoo.vespa.hosted.controller.deployment;
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+import java.util.Optional;
+
/**
* Contains details about a deployment job run.
*
@@ -7,26 +12,14 @@ package com.yahoo.vespa.hosted.controller.deployment;
*/
public class RunDetails {
- private final String deploymentLog;
- private final String convergenceLog;
- private final String testLog;
-
- public RunDetails(String deploymentLog, String convergenceLog, String testLog) {
- this.deploymentLog = deploymentLog;
- this.convergenceLog = convergenceLog;
- this.testLog = testLog;
- }
-
- public String getDeploymentLog() {
- return deploymentLog;
- }
+ private final Map<Step, byte[]> logs;
- public String getConvergenceLog() {
- return convergenceLog;
+ public RunDetails(Map<Step, byte[]> logs) {
+ this.logs = ImmutableMap.copyOf(logs);
}
- public String getTestLog() {
- return testLog;
+ public Optional<byte[]> get(Step step) {
+ return Optional.ofNullable(logs.get(step));
}
}