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

/**
 * There is one config proxy running on each Vespa host, and one instance of
 * this class is therefore created by each instance of class {@link
 * com.yahoo.vespa.model.Host}.
 *
 * NOTE: The Config proxy is not started by the config system, and
 * does not receive any config. It's included here so we know what host
 * it runs on, and to give an error message if another service tries
 * to reserve the port it is using.
 *
 * @author Vidar Larsen
 * @author Harald Musum
 */
public class ConfigProxy extends AbstractService {

    public final static int BASEPORT = 19090;

    /**
     * Creates a new ConfigProxy instance.
     *
     * @param host hostname
     */
    public ConfigProxy(Host host) {
        super(host, "configproxy");
        portsMeta.on(0).tag("rpc").tag("client").tag("status").tag("rpc").tag("admin");
        setProp("clustertype", "hosts");
        setProp("clustername", "admin");
    }

    @Override
    public void allocatePorts(int start, PortAllocBridge from) {
        if (start == 0) start = BASEPORT;
        from.requirePort(start, "rpc");
    }

    /**
     * Returns the desired base port for this service.
     */
    public int getWantedPort() { return BASEPORT; }

    /**
     * The desired base port is the only allowed base port.
     */
    public boolean requiresWantedPort() { return true; }

    /**
     * ConfigProxy needs one rpc client port.
     *
     * @return The number of ports reserved by the config proxy
     */
    public int getPortCount() { return 1; }

}