aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java
blob: 6acacdc50924f9273731747e1881e45340efa934 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.orchestrator.policy;

import com.yahoo.vespa.applicationmodel.ClusterId;
import com.yahoo.vespa.applicationmodel.InfrastructureApplication;
import com.yahoo.vespa.applicationmodel.ServiceType;

/**
 * Creates orchestration parameters for hosted Vespa.
 *
 * @author hakonhall
 */
public class HostedVespaOrchestration {
    public static OrchestrationParams create(int numConfigServers, int numProxies, int numProxiesAllowedDown,
                                             double numProxiesAllowedDownRatio) {
        // We'll create parameters for both the controller and config server applications, even though
        // only one of them is present, as (a) no harm is done by having the extra parameters, and
        // (b) it leads to simpler code below.

        return new OrchestrationParams.Builder()

                // Controller host
                .addApplicationParams(InfrastructureApplication.CONTROLLER_HOST,
                                      new ApplicationParams
                                              .Builder()
                                              .add(ClusterId.CONTROLLER,
                                                   ServiceType.HOST_ADMIN,
                                                   new ClusterParams
                                                           .Builder()
                                                           .setSize(numConfigServers)
                                                           .build())
                                              .build())

                // Controller
                .addApplicationParams(InfrastructureApplication.CONTROLLER,
                                      new ApplicationParams
                                              .Builder()
                                              .add(ClusterId.CONTROLLER,
                                                   ServiceType.CONTROLLER,
                                                   new ClusterParams
                                                           .Builder()
                                                           .setSize(numConfigServers)
                                                           .build())
                                              .build())

                // Config server host
                .addApplicationParams(InfrastructureApplication.CONFIG_SERVER_HOST,
                                      new ApplicationParams
                                              .Builder()
                                              .add(ClusterId.CONFIG_SERVER_HOST,
                                                   ServiceType.HOST_ADMIN,
                                                   new ClusterParams
                                                           .Builder()
                                                           .setSize(numConfigServers)
                                                           .build())
                                              .build())

                // Config server
                .addApplicationParams(InfrastructureApplication.CONFIG_SERVER,
                                      new ApplicationParams
                                              .Builder()
                                              .add(ClusterId.CONFIG_SERVER,
                                                   ServiceType.CONFIG_SERVER,
                                                   new ClusterParams
                                                           .Builder()
                                                           .setSize(numConfigServers)
                                                           .build())
                                              .build())

                // Proxy host
                .addApplicationParams(InfrastructureApplication.PROXY_HOST,
                                      new ApplicationParams
                                              .Builder()
                                              .add(ClusterId.PROXY_HOST,
                                                   ServiceType.HOST_ADMIN,
                                                   new ClusterParams
                                                           .Builder()
                                                           .setSize(numProxies)
                                                           .setAllowedDown(numProxiesAllowedDown)
                                                           .setAllowedDownRatio(numProxiesAllowedDownRatio)
                                                           .build())
                                              .build())

                // Proxy
                .addApplicationParams(InfrastructureApplication.PROXY,
                                      new ApplicationParams
                                              .Builder()
                                              .add(ClusterId.ROUTING,
                                                   ServiceType.CONTAINER,
                                                   new ClusterParams
                                                           .Builder()
                                                           .setSize(numProxies)
                                                           .setAllowedDown(numProxiesAllowedDown)
                                                           .setAllowedDownRatio(numProxiesAllowedDownRatio)
                                                           .build())
                                              .build())

                .build();
    }
}