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

import com.yahoo.cloud.config.log.LogdConfig;
import java.util.Optional;

/**
 * There is one logd running on each Vespa host, and one instance of
 * this class is therefore created by each instance of class {@link
 * Host}.
 *
 * @author gjoranv
 */
public class Logd
    extends AbstractService
    implements LogdConfig.Producer
{
    static final int BASEPORT = 19089;

    /**
     * Creates a new Logd instance.
     */
    public Logd(Host host) {
        super(host, "logd");
        setProp("clustertype", "hosts");
        setProp("clustername", "admin");
        portsMeta.on(0).tag("http").tag("state");
    }

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

    /**
     * Logd needs a state port.
     *
     * @return The number of ports reserved by the logd
     */
    public int getPortCount() { return 1; }

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

    /**
     * @return The command used to start logd
     */
    @Override
    public Optional<String> getStartupCommand() { return Optional.of("exec sbin/vespa-logd"); }

    @Override
    public int getHealthPort() { return getRelativePort(0); }

    public void getConfig(LogdConfig.Builder builder) {
        builder.stateport(getHealthPort());
    }
}