public Version getTargetVersionFor(NodeType nodeType) {
        assertLegalNodeTypeForTargetVersion(nodeType);

        return Optional.ofNullable(db.readInfrastructureVersions().get(nodeType)).orElseGet(() -> {
            // Target version has never been set for this node type, set it to the default version of this server.
            // We need to set the version (in ZK) to prevent another config server from returning a different version.
            // No lock needed since this is only an issue in bootstrap case and in a potential race, all versions
            // are equally valid
            setTargetVersion(nodeType, defaultVersion, false);
            return defaultVersion;
        });
    }
Multithread safe class to see and set target versions for infrastructure node types.
{@link InfrastructureProvisioner} maintainer will then allocate the nodes of given node type
with a wanted version equal to the given target version.

@author freva
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersions.java