blob: 337be9effe888777c8e1b806c1c964c6cd91aed6 (
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
|
// 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.config.model.api.ServiceInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* Representation of a process which runs a service
*
* @author gjoranv
*/
public interface Service extends ConfigProducer, NetworkPortRequestor {
/**
* Services that should be started by config-sentinel must return
* a non-empty value. The returned value will be used in config-sentinel
* configuration.
*/
Optional<String> getStartupCommand();
// environment variables specific for this service:
Map<String, Object> getEnvVars();
default List<LogctlSpec> getLogctlSpecs() { return List.of(); }
/**
* Services that wish that a command should be run before shutdown
* should return the command here. The command will be executed
* by the config sentinel before sending SIGTERM to the service.
* The command is executed without a timeout.
*/
Optional<String> getPreShutdownCommand();
/** Returns a PortsMeta object, giving access to more information about the different ports of this service. */
PortsMeta getPortsMeta();
/** Returns the physical host resource on which this service runs. */
HostResource getHost();
/**
* Get meta information about service.
* @return an instance of {@link com.yahoo.config.model.api.ServiceInfo}
*/
ServiceInfo getServiceInfo();
/** Returns the hostname on which this service runs. */
String getHostName();
/** Optional JVM execution options for this service */
String getJvmOptions();
/**
* Computes and returns the i'th port for this service, based on this Service's baseport.
*
* @param i the offset from 'basePort' of the port to return
* @return the i'th port relative to the base port
* @throws IllegalStateException if i is out of range
*/
int getRelativePort(int i);
/**
* Gets a service property value mapped to the given key
* as a String, or the value in <code>defStr</code> if no such key exists.
*
* @param key a key used for lookup in the service properties
* @param defStr default String value returned if no value for key found
* @return the associated String value for the given key
*/
String getServicePropertyString(String key, String defStr);
int getHealthPort();
/** Returns a HashMap of default dimensions for metrics. */
HashMap<String,String> getDefaultMetricDimensions();
/** Returns the Affinity of this service if it has. */
Optional<Affinity> getAffinity();
}
|