aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/admin/clustercontroller/ClusterControllerConfigurer.java
blob: 27289e474d8f5fcc5f0c35c992328de91411744b (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.admin.clustercontroller;

import com.yahoo.component.ComponentSpecification;
import com.yahoo.vespa.config.content.FleetcontrollerConfig;
import com.yahoo.vespa.config.content.StorDistributionConfig;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.vespa.model.container.component.SimpleComponent;
import com.yahoo.vespa.model.content.cluster.ContentCluster;

/**
 * Model serving class. Wraps fleet controller config serving.
 */
public class ClusterControllerConfigurer extends SimpleComponent implements StorDistributionConfig.Producer,
        FleetcontrollerConfig.Producer
{
    private final ContentCluster cluster;
    private final int clusterControllerIndex;
    private final int nodeCount;

    public ClusterControllerConfigurer(ContentCluster cluster, int clusterControllerIndex, int nodeCount) {
        super(new ComponentModel(new BundleInstantiationSpecification(
                new ComponentSpecification("clustercontroller" + "-" + cluster.getName() + "-configurer"),
                new ComponentSpecification("com.yahoo.vespa.clustercontroller.apps.clustercontroller.ClusterControllerClusterConfigurer"),
                new ComponentSpecification("clustercontroller-apps"))));
        this.cluster = cluster;
        this.clusterControllerIndex = clusterControllerIndex;
        this.nodeCount = nodeCount;
    }

    @Override
    public void getConfig(StorDistributionConfig.Builder builder) {
        cluster.getConfig(builder);
    }

    @Override
    public void getConfig(FleetcontrollerConfig.Builder builder) {
        cluster.getConfig(builder);
        cluster.getClusterControllerConfig().getConfig(builder);
        builder.index(clusterControllerIndex);
        builder.fleet_controller_count(nodeCount);
        builder.http_port(0);
        builder.rpc_port(0);
    }

}