blob: 2b9551c2858b1307d596fc090bd549b05ff601e0 (
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
|
// Copyright 2017 Yahoo Holdings. 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.api.ModelContext;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.config.core.StateserverConfig;
import com.yahoo.vespa.model.AbstractService;
import com.yahoo.vespa.model.PortAllocBridge;
/**
* Represents a Slobrok service.
*
* @author gjoranv
*/
public class Slobrok extends AbstractService implements StateserverConfig.Producer {
private static final long serialVersionUID = 1L;
public final static int BASEPORT = 19099;
@Override
public void getConfig(StateserverConfig.Builder builder) {
builder.httpport(getHealthPort());
}
/**
* @param parent the parent ConfigProducer.
* @param index unique index for all slobroks
*/
public Slobrok(AbstractConfigProducer<?> parent, int index,
ModelContext.FeatureFlags featureFlags)
{
super(parent, "slobrok." + index);
portsMeta.on(0).tag("rpc").tag("admin").tag("status");
portsMeta.on(1).tag("http").tag("state");
setProp("index", index);
setProp("clustertype", "slobrok");
setProp("clustername", "admin");
}
@Override
public int getWantedPort() {
if (getId() == 1) {
return BASEPORT;
} else {
return 0;
}
}
public String getStartupCommand() {
return "exec $ROOT/sbin/vespa-slobrok -N -p " + getRpcPort() + " -c " + getConfigId();
}
@Override
public void allocatePorts(int start, PortAllocBridge from) {
if (start == 0) start = BASEPORT;
from.wantPort(start, "rpc");
from.allocatePort("http");
}
/**
* @return The number of ports needed by the slobrok.
*/
public int getPortCount() {
return 2;
}
/**
* @return The port on which this slobrok should respond
*/
private int getRpcPort() {
return getRelativePort(0);
}
/**
* @return The port on which the state server should respond
*/
@Override
public int getHealthPort() {
return getRelativePort(1);
}
/**
* @return The connection spec to this Slobrok
*/
public String getConnectionSpec() {
return "tcp/" + getHostName() + ":" + getRpcPort();
}
}
|