summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2018-10-25 18:28:18 +0200
committerJon Marius Venstad <venstad@gmail.com>2018-10-25 18:28:18 +0200
commit727ca19dfcff5aef8d04c16b81c6718f18928aab (patch)
tree72bd844b610ad87489514d851cc982f90666245a
parent6a6f6f8f6695ff8f39132303ca460665882ccaf6 (diff)
Batch log calls that go to ZK when trivial
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java34
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java16
2 files changed, 34 insertions, 16 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
index a3d1d389481..5fd197eb785 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java
@@ -40,6 +40,7 @@ import java.io.UncheckedIOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -276,15 +277,17 @@ public class InternalStepRunner implements StepRunner {
private boolean nodesConverged(ApplicationId id, JobType type, Version target, DualLogger logger) {
List<Node> nodes = controller.configServer().nodeRepository().list(type.zone(controller.system()), id, ImmutableSet.of(active, reserved));
- for (Node node : nodes)
- logger.log(String.format("%70s: %-16s%-25s%-32s%s",
+ List<String> statuses = nodes.stream()
+ .map(node -> String.format("%70s: %-16s%-25s%-32s%s",
node.hostname(),
node.serviceState(),
node.wantedVersion() + (node.currentVersion().equals(node.wantedVersion()) ? "" : " <-- " + node.currentVersion()),
node.restartGeneration() == node.wantedRestartGeneration() ? ""
: "restart pending (" + node.wantedRestartGeneration() + " <-- " + node.restartGeneration() + ")",
node.rebootGeneration() == node.wantedRebootGeneration() ? ""
- : "reboot pending (" + node.wantedRebootGeneration() + " <-- " + node.rebootGeneration() + ")"));
+ : "reboot pending (" + node.wantedRebootGeneration() + " <-- " + node.rebootGeneration() + ")"))
+ .collect(Collectors.toList());
+ logger.log(statuses);
return nodes.stream().allMatch(node -> node.currentVersion().equals(target)
&& node.restartGeneration() == node.wantedRestartGeneration()
@@ -298,13 +301,16 @@ public class InternalStepRunner implements StepRunner {
return false;
}
logger.log("Wanted config generation is " + convergence.get().wantedGeneration());
- for (ServiceConvergence.Status serviceStatus : convergence.get().services())
- if (serviceStatus.currentGeneration() != convergence.get().wantedGeneration())
- logger.log(String.format("%70s: %11s on port %4d has %s",
- serviceStatus.host().value(),
- serviceStatus.type(),
- serviceStatus.port(),
- serviceStatus.currentGeneration() == -1 ? "(unknown)" : Long.toString(serviceStatus.currentGeneration())));
+ List<String> statuses = convergence.get().services().stream()
+ .filter(serviceStatus -> serviceStatus.currentGeneration() != convergence.get().wantedGeneration())
+ .map(serviceStatus -> String.format("%70s: %11s on port %4d has %s",
+ serviceStatus.host().value(),
+ serviceStatus.type(),
+ serviceStatus.port(),
+ serviceStatus.currentGeneration() == -1 ? "(unknown)" : Long.toString(serviceStatus.currentGeneration())))
+ .collect(Collectors.toList());
+ logger.log(statuses);
+
return convergence.get().converged();
}
@@ -578,8 +584,12 @@ public class InternalStepRunner implements StepRunner {
this.step = step;
}
- private void log(String message) {
- log(DEBUG, message);
+ private void log(String... messages) {
+ log(Arrays.asList(messages));
+ }
+
+ private void log(List<String> messages) {
+ controller.jobController().log(id, step, DEBUG, messages);
}
private void log(Level level, String message) {
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 1b45041abce..a75c3d2f8f3 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
@@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.UnaryOperator;
import java.util.logging.Level;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.google.common.collect.ImmutableList.copyOf;
@@ -102,15 +103,22 @@ public class JobController {
}
}
- /** Stores the given log record for the given run and step. */
- public void log(RunId id, Step step, Level level, String message) {
+ /** Stores the given log records for the given run and step. */
+ public void log(RunId id, Step step, Level level, List<String> messages) {
locked(id, __ -> {
- LogEntry entry = new LogEntry(0, controller.clock().millis(), LogEntry.typeOf(level), message);
- logs.append(id.application(), id.type(), step, Collections.singletonList(entry));
+ List<LogEntry> entries = messages.stream()
+ .map(message -> new LogEntry(0, controller.clock().millis(), LogEntry.typeOf(level), message))
+ .collect(Collectors.toList());
+ logs.append(id.application(), id.type(), step, entries);
return __;
});
}
+ /** Stores the given log record for the given run and step. */
+ public void log(RunId id, Step step, Level level, String message) {
+ log(id, step, level, Collections.singletonList(message));
+ }
+
/** Fetches any new test log entries, and records the id of the last of these, for continuation. */
public void updateTestLog(RunId id) {
locked(id, run -> {