blob: f2cfb9193f5ae5d98f530872f7cbe56eae9bfdf8 (
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
|
// 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;
import com.yahoo.config.model.producer.TreeConfigProducer;
import com.yahoo.vespa.model.AbstractService;
import com.yahoo.vespa.model.PortAllocBridge;
/**
* Represents a Configserver. There may be one or more Configservers in a
* Vespa system.
*
* NOTE: The Configserver 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 ports it is using.
*
* @author gjoranv
*/
public class Configserver extends AbstractService {
private static final long serialVersionUID = 1L;
public static final int defaultRpcPort = 19070;
private final int rpcPort;
public Configserver(TreeConfigProducer<? super Configserver> parent, String name, int rpcPort) {
super(parent, name);
this.rpcPort = rpcPort;
portsMeta.on(0).tag("rpc").tag("config");
portsMeta.on(1).tag("http").tag("config").tag("state");
setProp("clustertype", "admin");
setProp("clustername", "admin");
}
@Override
public void allocatePorts(int start, PortAllocBridge from) {
if (requiresWantedPort()) {
from.requirePort(start++, "rpc");
from.requirePort(start++, "http");
} else if (start == 0) {
from.allocatePort("rpc");
from.allocatePort("http");
} else {
from.wantPort(start++, "rpc");
from.wantPort(start++, "http");
}
}
/**
* Returns the desired base port for this service.
*/
public int getWantedPort() {
return rpcPort;
}
/**
* The desired base port is the only allowed base port.
* @return 'true' always
*/
public boolean requiresWantedPort() {
return getId() < 2;
}
/**
* @return the number of ports needed by the configserver.
*/
public int getPortCount() { return 2; }
private int getConfigServerRpcPort() {
return getRelativePort(0);
}
private int getConfigServerHttpPort() {
return getRelativePort(1);
}
@Override
public int getHealthPort() {
return getRelativePort(1);
}
}
|