All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.vespa.hosted.provision.lb.SharedLoadBalancerService Maven / Gradle / Ivy

The newest version!
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.lb;

import ai.vespa.http.DomainName;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.EndpointsChecker.Availability;
import com.yahoo.config.provision.EndpointsChecker.Endpoint;
import com.yahoo.config.provision.NodeType;

import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

/**
 * This implementation of {@link LoadBalancerService} returns the load balancer(s) that exist by default in the shared
 * routing layer.
 * 

* Since such load balancers always exist, we can return the hostname of the routing layer VIP directly. Nothing has to * be provisioned. * * @author ogronnesby */ public class SharedLoadBalancerService implements LoadBalancerService { private final String vipHostname; public SharedLoadBalancerService(String vipHostname) { this.vipHostname = Objects.requireNonNull(vipHostname); } @Override public LoadBalancerInstance provision(LoadBalancerSpec spec) { if ( ! spec.settings().isPublicEndpoint()) throw new IllegalArgumentException("non-public endpoints is not supported with " + getClass()); return new LoadBalancerInstance(Optional.of(DomainName.of(vipHostname)), Optional.empty(), Optional.empty(), Optional.empty(), Set.of(4443), Set.of(), spec.reals(), spec.settings(), List.of(), spec.cloudAccount()); } @Override public LoadBalancerInstance configure(LoadBalancerInstance instance, LoadBalancerSpec spec, boolean force) { return instance.with(spec.reals(), spec.settings(), Optional.empty()); } @Override public void reallocate(LoadBalancerSpec spec) { throw new UnsupportedOperationException("reallocate is not supported with " + getClass()); } @Override public void remove(LoadBalancer loadBalancer) { // Do nothing, we have no external state to modify } @Override public Protocol protocol(boolean enclave) { if (enclave) throw new IllegalArgumentException("enclave is not supported with " + getClass()); return Protocol.dualstack; } @Override public boolean supports(NodeType nodeType, ClusterSpec.Type clusterType) { // Shared routing layer only supports routing to tenant nodes return nodeType == NodeType.tenant && clusterType.isContainer(); } @Override public Availability healthy(Endpoint endpoint, String idSeed) { return Availability.ready; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy