summaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/lb/LoadBalancerService.java
blob: 6ddde1151dda587301b37113e4880adcfe277006 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 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 com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.EndpointsChecker.Availability;
import com.yahoo.config.provision.EndpointsChecker.Endpoint;
import com.yahoo.config.provision.EndpointsChecker.HealthChecker;
import com.yahoo.config.provision.NodeType;

import java.util.Optional;

/**
 * A managed load balance service.
 *
 * @author mpolden
 */
public interface LoadBalancerService {

    /**
     * Provisions load balancers from the given specification. Implementations are expected to be idempotent
     *
     * @param spec        Load balancer specification
     * @return The provisioned load balancer instance
     */
    default LoadBalancerInstance provision(LoadBalancerSpec spec) { return provision(spec, Optional.empty()); }

    /**
     * Provisions load balancers from the given specification. Implementations are expected to be idempotent
     *
     * @param spec        Load balancer specification
     * @param idSeed      Seed for generating a unique ID for the load balancer instance
     * @return The provisioned load balancer instance
     */
    LoadBalancerInstance provision(LoadBalancerSpec spec, Optional<String> idSeed);

    /**
     * Configures load balancers for the given specification. Implementations are expected to be idempotent
     *
     * @param instance    Load balancer instance to reconfigure
     * @param spec        Load balancer specification
     * @param force       Whether reconfiguration should be forced (e.g. allow configuring an empty set of reals on a
     *                    pre-existing load balancer, or removing an unused private endpoint service load balancer).
     * @return The (re)configured load balancer instance
     */
    LoadBalancerInstance configure(LoadBalancerInstance instance, LoadBalancerSpec spec, boolean force);

    void reallocate(LoadBalancerInstance provisioned, LoadBalancerSpec spec);

    /** Permanently remove given load balancer */
    void remove(LoadBalancer loadBalancer);

    /** Returns the protocol supported by this load balancer service */
    Protocol protocol(boolean enclave);

    /** Returns whether load balancers created by this service can forward traffic to given node and cluster type */
    boolean supports(NodeType nodeType, ClusterSpec.Type clusterType);

    /** See {@link HealthChecker#healthy(Endpoint)}. */
    Availability healthy(Endpoint endpoint, Optional<String> idSeed);

    /** Load balancer protocols */
    enum Protocol {
        ipv4,
        ipv6,
        dualstack
    }

}