use of com.yahoo.vespa.hosted.provision.node.History in project vespa by vespa-engine.
the class Node method withCurrentRebootGeneration.
/**
* Returns a copy of this node with the current reboot generation set to the given number at the given instant
*/
public Node withCurrentRebootGeneration(long generation, Instant instant) {
Status newStatus = status().withReboot(status().reboot().withCurrent(generation));
History newHistory = history();
if (generation > status().reboot().current())
newHistory = history.with(new History.Event(History.Event.Type.rebooted, Agent.system, instant));
return this.with(newStatus).with(newHistory);
}
use of com.yahoo.vespa.hosted.provision.node.History in project vespa by vespa-engine.
the class NodesResponse method toSlime.
private void toSlime(History history, Cursor array) {
for (History.Event event : history.events()) {
Cursor object = array.addObject();
object.setString("event", event.type().name());
object.setLong("at", event.at().toEpochMilli());
object.setString("agent", event.agent().name());
}
}
use of com.yahoo.vespa.hosted.provision.node.History in project vespa by vespa-engine.
the class NodesResponse method toSlime.
private void toSlime(Node node, boolean allFields, Cursor object) {
object.setString("url", nodeParentUrl + node.hostname());
if (!allFields)
return;
object.setString("id", node.id());
object.setString("state", NodeStateSerializer.wireNameOf(node.state()));
object.setString("type", node.type().name());
object.setString("hostname", node.hostname());
object.setString("type", toString(node.type()));
if (node.parentHostname().isPresent()) {
object.setString("parentHostname", node.parentHostname().get());
}
object.setString("openStackId", node.openStackId());
object.setString("flavor", node.flavor().name());
object.setString("canonicalFlavor", node.flavor().canonicalName());
object.setDouble("minDiskAvailableGb", node.flavor().getMinDiskAvailableGb());
object.setDouble("minMainMemoryAvailableGb", node.flavor().getMinMainMemoryAvailableGb());
if (node.flavor().getDescription() != null && !node.flavor().getDescription().isEmpty())
object.setString("description", node.flavor().getDescription());
object.setDouble("minCpuCores", node.flavor().getMinCpuCores());
if (node.flavor().cost() > 0)
object.setLong("cost", node.flavor().cost());
object.setBool("fastDisk", node.flavor().hasFastDisk());
object.setString("environment", node.flavor().getType().name());
if (node.allocation().isPresent()) {
toSlime(node.allocation().get().owner(), object.setObject("owner"));
toSlime(node.allocation().get().membership(), object.setObject("membership"));
object.setLong("restartGeneration", node.allocation().get().restartGeneration().wanted());
object.setLong("currentRestartGeneration", node.allocation().get().restartGeneration().current());
object.setString("wantedDockerImage", nodeRepository.dockerImage().withTag(node.allocation().get().membership().cluster().vespaVersion()).asString());
object.setString("wantedVespaVersion", node.allocation().get().membership().cluster().vespaVersion().toFullString());
try {
object.setBool("allowedToBeDown", orchestrator.getNodeStatus(new HostName(node.hostname())) == HostStatus.ALLOWED_TO_BE_DOWN);
} catch (HostNameNotFoundException e) {
/* ok */
}
}
object.setLong("rebootGeneration", node.status().reboot().wanted());
object.setLong("currentRebootGeneration", node.status().reboot().current());
node.status().vespaVersion().filter(version -> !version.isEmpty()).ifPresent(version -> {
object.setString("vespaVersion", version.toFullString());
object.setString("currentDockerImage", nodeRepository.dockerImage().withTag(version).asString());
// TODO: Remove these when they are no longer read
object.setString("hostedVersion", version.toFullString());
object.setString("convergedStateVersion", version.toFullString());
});
object.setLong("failCount", node.status().failCount());
object.setBool("hardwareFailure", node.status().hardwareFailureDescription().isPresent());
node.status().hardwareFailureDescription().ifPresent(failure -> object.setString("hardwareFailureDescription", failure));
object.setBool("wantToRetire", node.status().wantToRetire());
object.setBool("wantToDeprovision", node.status().wantToDeprovision());
toSlime(node.history(), object.setArray("history"));
ipAddressesToSlime(node.ipAddresses(), object.setArray("ipAddresses"));
ipAddressesToSlime(node.additionalIpAddresses(), object.setArray("additionalIpAddresses"));
node.status().hardwareDivergence().ifPresent(hardwareDivergence -> object.setString("hardwareDivergence", hardwareDivergence));
}
use of com.yahoo.vespa.hosted.provision.node.History in project vespa by vespa-engine.
the class NodeFailer method updateNodeLivenessEventsForReadyNodes.
private void updateNodeLivenessEventsForReadyNodes() {
// We do this here ("lazily") to avoid writing to zk for each config request.
for (Node node : nodeRepository().getNodes(Node.State.ready)) {
Optional<Instant> lastLocalRequest = hostLivenessTracker.lastRequestFrom(node.hostname());
if (!lastLocalRequest.isPresent())
continue;
Optional<History.Event> recordedRequest = node.history().event(History.Event.Type.requested);
if (!recordedRequest.isPresent() || recordedRequest.get().at().isBefore(lastLocalRequest.get())) {
History updatedHistory = node.history().with(new History.Event(History.Event.Type.requested, Agent.system, lastLocalRequest.get()));
nodeRepository().write(node.with(updatedHistory));
}
}
}
Aggregations