Package com.yahoo.vespa.model.container
Class Container
java.lang.Object
com.yahoo.config.model.producer.AnyConfigProducer
com.yahoo.config.model.producer.TreeConfigProducer<AnyConfigProducer>
com.yahoo.vespa.model.AbstractService
com.yahoo.vespa.model.container.Container
- All Implemented Interfaces:
com.yahoo.config.ConfigInstance.Producer
,com.yahoo.container.ComponentsConfig.Producer
,com.yahoo.container.core.ContainerHttpConfig.Producer
,com.yahoo.container.jdisc.ContainerMbusConfig.Producer
,com.yahoo.container.jdisc.JdiscBindingsConfig.Producer
,com.yahoo.container.QrConfig.Producer
,ConfigProducer
,NetworkPortRequestor
,Service
,Serializable
- Direct Known Subclasses:
ApplicationContainer
,ClusterControllerContainer
,LogserverContainer
,MetricsProxyContainer
public abstract class Container
extends AbstractService
implements com.yahoo.container.QrConfig.Producer, com.yahoo.container.ComponentsConfig.Producer, com.yahoo.container.jdisc.JdiscBindingsConfig.Producer, com.yahoo.container.core.ContainerHttpConfig.Producer, com.yahoo.container.jdisc.ContainerMbusConfig.Producer
Note about components: In general, all components should belong to the cluster and not the container. However,
components that need node specific config must be added at the container level, along with the node-specific
parts of the config generation (getConfig).
- Author:
- gjoranv, Einar M R Rosenvinge, Tony Vaagenes
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected int
protected int
static final int
protected final TreeConfigProducer<?>
static final String
Fields inherited from class com.yahoo.vespa.model.AbstractService
portsMeta
Fields inherited from class com.yahoo.config.model.producer.AnyConfigProducer
log
-
Constructor Summary
ModifierConstructorDescriptionprotected
Container
(TreeConfigProducer<?> parent, String name, boolean retired, int index, DeployState deployState) protected
Container
(TreeConfigProducer<?> parent, String name, int index, DeployState deployState) -
Method Summary
Modifier and TypeMethodDescriptionvoid
final void
final void
final void
addSimpleComponent
(String idSpec, String classSpec, String bundleSpec) void
allocatePorts
(int start, PortAllocBridge from) allocate the ports you needprotected Optional<ContainerCluster>
Returns the jvm args set explicitly for this nodevoid
getConfig
(com.yahoo.container.ComponentsConfig.Builder builder) void
getConfig
(com.yahoo.container.core.ContainerHttpConfig.Builder builder) void
getConfig
(com.yahoo.container.jdisc.ContainerMbusConfig.Builder builder) final void
getConfig
(com.yahoo.container.jdisc.JdiscBindingsConfig.Builder builder) void
getConfig
(com.yahoo.container.QrConfig.Builder builder) Overridden by subclasses.int
The service HTTP port for health statusgetHttp()
int
Returns the number of ports needed by this service.protected int
int
final String
Subclasses must implementmyServiceType()
for a custom service name.Must be overridden by services that should be started by config-sentinel.int
Returns the desired base port for the first instance of the service type.final int
index()
Returns the index of this node.void
initService
(DeployState deployState) Called by builder class which has not given the host or port in a constructor, hence initService is not yet run for this.boolean
True if this container is retired (slated for removal)protected String
jvmOmitStackTraceInFastThrowOption
(com.yahoo.config.model.api.ModelContext.FeatureFlags featureFlags) protected abstract com.yahoo.config.model.api.container.ContainerServiceType
Subclasses must implement this for a custom service name.protected int
protected int
protected String
prepareStopCommand
(Duration timeout) boolean
First container must run on ports familiar to the user.void
setClusterName
(String name) void
setHostResponseHeaderKey
(Optional<String> hostResponseheaderKey) If present, this container should emit this header key with the value set to the local hostname in HTTP responsesvoid
instance can use any port number for its default HTTP serverMethods inherited from class com.yahoo.vespa.model.AbstractService
addEnvironmentVariable, addEnvironmentVariable, appendJvmOptions, defaultPreload, distributeCpuSocketAffinity, getAffinity, getEnvStringForTesting, getEnvVars, getHost, getHostName, getHostResource, getId, getIndex, getJvmOptions, getNumPortsAllocated, getPortsMeta, getPreLoad, getPreShutdownCommand, getRelativePort, getServiceInfo, getServiceName, getServicePropertyString, getServicePropertyString, isInitialized, prependJvmOptions, remove, setAffinity, setBasePort, setCoreOnOOM, setHostResource, setJvmOptions, setMMapNoCoreLimit, setNoVespaMalloc, setPreLoad, setProp, setProp, setVespaMalloc, setVespaMallocDebug, setVespaMallocDebugStackTrace, toString
Methods inherited from class com.yahoo.config.model.producer.TreeConfigProducer
addChild, addDescendantService, getChildren, getChildrenByTypeRecursive, getConfigClassLoader, getDescendantServices, removeChild, validate
Methods inherited from class com.yahoo.config.model.producer.AnyConfigProducer
addConfigId, addUserConfig, cascadeConfig, currentConfigId, findInheritedClassLoader, getConfigId, getMonitoringService, getParent, getRoot, getSubId, getUserConfigs, hostSystem, mergeUserConfigs, setParent, setUserConfigs, stateIsHosted
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.yahoo.vespa.model.ConfigProducer
addUserConfig, cascadeConfig, dump, getChildren, getConfigId, getDescendantServices, getUserConfigs, hostSystem, validate
Methods inherited from interface com.yahoo.vespa.model.NetworkPortRequestor
getConfigId
-
Field Details
-
BASEPORT
public static final int BASEPORT -
SINGLENODE_CONTAINER_SERVICESPEC
- See Also:
-
parent
-
allocatedSearchPort
protected int allocatedSearchPort -
allocatedRpcPort
protected int allocatedRpcPort -
allocatedMessagingPort
protected int allocatedMessagingPort
-
-
Constructor Details
-
Container
-
Container
protected Container(TreeConfigProducer<?> parent, String name, boolean retired, int index, DeployState deployState)
-
-
Method Details
-
jvmOmitStackTraceInFastThrowOption
protected String jvmOmitStackTraceInFastThrowOption(com.yahoo.config.model.api.ModelContext.FeatureFlags featureFlags) -
isRetired
public boolean isRetired()True if this container is retired (slated for removal) -
getHandlers
-
getComponents
-
addComponent
-
addSimpleComponent
-
addHandler
-
setHostResponseHeaderKey
If present, this container should emit this header key with the value set to the local hostname in HTTP responses -
getHttp
-
getDefaultHttpServer
-
index
public final int index()Returns the index of this node. The index of a given node is stable through changes with best effort. -
addBuiltinHandlers
public void addBuiltinHandlers() -
initService
Description copied from class:AbstractService
Called by builder class which has not given the host or port in a constructor, hence initService is not yet run for this.- Overrides:
initService
in classAbstractService
-
getServiceType
Subclasses must implementmyServiceType()
for a custom service name.- Specified by:
getServiceType
in interfaceNetworkPortRequestor
- Overrides:
getServiceType
in classAbstractService
-
myServiceType
protected abstract com.yahoo.config.model.api.container.ContainerServiceType myServiceType()Subclasses must implement this for a custom service name. -
setClusterName
-
getWantedPort
public int getWantedPort()Description copied from class:AbstractService
Returns the desired base port for the first instance of the service type. Returns '0' as default, which means that the service type should use the default port allocation mechanism.- Specified by:
getWantedPort
in interfaceNetworkPortRequestor
- Overrides:
getWantedPort
in classAbstractService
- Returns:
- The desired base port for the first instance of the service type.
-
useDynamicPorts
public void useDynamicPorts()instance can use any port number for its default HTTP server -
requiresWantedPort
public boolean requiresWantedPort()First container must run on ports familiar to the user.- Specified by:
requiresWantedPort
in interfaceNetworkPortRequestor
- Overrides:
requiresWantedPort
in classAbstractService
- Returns:
- false by default
-
getPortCount
public int getPortCount()Description copied from interface:NetworkPortRequestor
Returns the number of ports needed by this service. User-defined ports for container http servers should not be counted, as those ports are required to be outside Vespa's port range.- Specified by:
getPortCount
in interfaceNetworkPortRequestor
- Returns:
- the number of ports needed by the Container
-
allocatePorts
Description copied from interface:NetworkPortRequestor
allocate the ports you need- Specified by:
allocatePorts
in interfaceNetworkPortRequestor
-
getSearchPort
public int getSearchPort()- Returns:
- the actual search port
TODO: Remove. Use
AbstractService.getPortsMeta()
and check tags in conjunction withAbstractService.getRelativePort(int)
.
-
getRpcPort
protected int getRpcPort() -
numRpcPorts
protected int numRpcPorts() -
numMessageBusPorts
protected int numMessageBusPorts() -
getHealthPort
public int getHealthPort()Description copied from class:AbstractService
The service HTTP port for health status- Specified by:
getHealthPort
in interfaceService
- Overrides:
getHealthPort
in classAbstractService
-
getStartupCommand
Description copied from class:AbstractService
Must be overridden by services that should be started by config-sentinel. The returned value will be used in config-sentinel configuration. Returns empty by default.- Specified by:
getStartupCommand
in interfaceService
- Overrides:
getStartupCommand
in classAbstractService
- Returns:
- empty by default.
-
getConfig
public void getConfig(com.yahoo.container.QrConfig.Builder builder) - Specified by:
getConfig
in interfacecom.yahoo.container.QrConfig.Producer
-
getAssignedJvmOptions
Returns the jvm args set explicitly for this node -
getConfig
public void getConfig(com.yahoo.container.ComponentsConfig.Builder builder) - Specified by:
getConfig
in interfacecom.yahoo.container.ComponentsConfig.Producer
-
getConfig
public final void getConfig(com.yahoo.container.jdisc.JdiscBindingsConfig.Builder builder) - Specified by:
getConfig
in interfacecom.yahoo.container.jdisc.JdiscBindingsConfig.Producer
-
getConfig
public void getConfig(com.yahoo.container.core.ContainerHttpConfig.Builder builder) - Specified by:
getConfig
in interfacecom.yahoo.container.core.ContainerHttpConfig.Producer
-
getConfig
public void getConfig(com.yahoo.container.jdisc.ContainerMbusConfig.Builder builder) - Specified by:
getConfig
in interfacecom.yahoo.container.jdisc.ContainerMbusConfig.Producer
-
getDefaultMetricDimensions
Description copied from class:AbstractService
Overridden by subclasses. List of default dimensions to be added to this services metrics- Specified by:
getDefaultMetricDimensions
in interfaceService
- Overrides:
getDefaultMetricDimensions
in classAbstractService
- Returns:
- the default dimensions for this service
-
prepareStopCommand
-
containerCluster
-
getLogctlSpecs
- Specified by:
getLogctlSpecs
in interfaceService
-