
com.yahoo.vespa.hosted.provision.os.OsVersions Maven / Gradle / Ivy
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.os;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.yahoo.component.Version;
import com.yahoo.config.provision.NodeType;
import com.yahoo.vespa.curator.Lock;
import com.yahoo.vespa.hosted.provision.persistence.CuratorDatabaseClient;
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
/**
* Thread-safe class that manages target OS versions for nodes in this repository.
*
* The target OS version for each node type is set through the /nodes/v2/upgrade REST API.
*
* @author mpolden
*/
public class OsVersions {
private static final Duration defaultCacheTtl = Duration.ofMinutes(1);
private static final Logger log = Logger.getLogger(OsVersions.class.getName());
private final CuratorDatabaseClient db;
private final Duration cacheTtl;
/**
* Target OS version is read on every request to /nodes/v2/node/[fqdn]. Cache current targets to avoid
* unnecessary ZK reads. When targets change, some nodes may need to wait for TTL until they see the new target,
* this is fine.
*/
private volatile Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy