Package com.yahoo.vespa.model.container
Class Container
- java.lang.Object
-
- com.yahoo.config.model.producer.AbstractConfigProducer<AbstractConfigProducer<?>>
-
- 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
,java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
allocatedMessagingPort
protected int
allocatedRpcPort
protected int
allocatedSearchPort
static int
BASEPORT
protected AbstractConfigProducer
parent
static java.lang.String
SINGLENODE_CONTAINER_SERVICESPEC
-
Fields inherited from class com.yahoo.vespa.model.AbstractService
portsMeta
-
Fields inherited from class com.yahoo.config.model.producer.AbstractConfigProducer
log
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Container(AbstractConfigProducer parent, java.lang.String name, boolean retired, int index)
protected
Container(AbstractConfigProducer parent, java.lang.String name, int index)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addBuiltinHandlers()
void
addComponent(Component c)
void
addHandler(Handler h)
void
addSimpleComponent(java.lang.String idSpec, java.lang.String classSpec, java.lang.String bundleSpec)
void
allocatePorts(int start, PortAllocBridge from)
allocate the ports you needjava.lang.String
getAssignedJvmOptions()
Returns the jvm args set explicitly for this nodeComponentGroup
getComponents()
void
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)
void
getConfig(com.yahoo.container.jdisc.JdiscBindingsConfig.Builder builder)
void
getConfig(com.yahoo.container.QrConfig.Builder builder)
JettyHttpServer
getDefaultHttpServer()
java.util.HashMap<java.lang.String,java.lang.String>
getDefaultMetricDimensions()
Overridden by subclasses.ComponentGroup<Handler<?>>
getHandlers()
int
getHealthPort()
The service HTTP port for health statusHttp
getHttp()
JettyHttpServer
getHttpServer()
int
getPortCount()
Returns the number of ports needed by this service.int
getSearchPort()
java.lang.String
getServiceType()
Subclasses must implementmyServiceType()
for a custom service name.java.lang.String
getStartupCommand()
Must be overridden by services that should be started by config-sentinel.int
getWantedPort()
Returns the desired base port for the first instance of the service type.int
index()
Returns the index of this node.void
initService(com.yahoo.config.application.api.DeployLogger deployLogger)
Called by builder class which has not given the host or port in a constructor, hence initService is not yet run for this.boolean
isRetired()
True if this container is retired (slated for removal)protected abstract com.yahoo.config.model.api.container.ContainerServiceType
myServiceType()
Subclasses must implement this for a custom service name.protected int
numMessageBusPorts()
protected int
numRpcPorts()
boolean
requiresWantedPort()
First Qrserver or container must run on ports familiar to the user.void
setClusterName(java.lang.String name)
void
setHostResponseHeaderKey(java.util.Optional<java.lang.String> hostResponseheaderKey)
If present, this container should emit this header key with the value set to the local hostname in HTTP responsesvoid
useDynamicPorts()
instance can use any port number for its default HTTP server-
Methods inherited from class com.yahoo.vespa.model.AbstractService
appendJvmOptions, distributeCpuSocketAffinity, getAffinity, getCoreOnOOM, getCoreOnOOMEnvVariable, getEnvVariables, getHost, getHostName, getHostResource, getId, getIndex, getJvmOptions, getMMapNoCoreEnvVariable, getMMapNoCoreLimit, getNoVespaMalloc, getNoVespaMallocEnvVariable, getNumPortsAllocated, getPortsMeta, getPreLoad, getPreShutdownCommand, getRelativePort, getServiceInfo, getServiceName, getServicePropertyString, getServicePropertyString, getVespaMalloc, getVespaMallocDebug, getVespaMallocDebugEnvVariable, getVespaMallocDebugStackTrace, getVespaMallocDebugStackTraceEnvVariable, getVespaMallocEnvVariable, isInitialized, prependJvmOptions, sendFile, sendUri, setAffinity, setBasePort, setCoreOnOOM, setHostResource, setJvmOptions, setMMapNoCoreLimit, setNoVespaMalloc, setPreLoad, setProp, setProp, setVespaMalloc, setVespaMallocDebug, setVespaMallocDebugStackTrace, toString
-
Methods inherited from class com.yahoo.config.model.producer.AbstractConfigProducer
addChild, addConfigId, addDescendantService, addUserConfig, cascadeConfig, dump, getChildren, getChildrenByTypeRecursive, getConfigClassLoader, getConfigId, getDescendantServices, getMonitoringService, getParent, getRoot, getSubId, getUserConfigs, hostSystem, mergeUserConfigs, removeChild, setParent, setUserConfigs, stateIsHosted, validate
-
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 Detail
-
BASEPORT
public static final int BASEPORT
-
SINGLENODE_CONTAINER_SERVICESPEC
public static final java.lang.String SINGLENODE_CONTAINER_SERVICESPEC
- See Also:
- Constant Field Values
-
parent
protected final AbstractConfigProducer parent
-
allocatedSearchPort
protected int allocatedSearchPort
-
allocatedRpcPort
protected int allocatedRpcPort
-
allocatedMessagingPort
protected int allocatedMessagingPort
-
-
Constructor Detail
-
Container
protected Container(AbstractConfigProducer parent, java.lang.String name, int index)
-
Container
protected Container(AbstractConfigProducer parent, java.lang.String name, boolean retired, int index)
-
-
Method Detail
-
isRetired
public boolean isRetired()
True if this container is retired (slated for removal)
-
getHandlers
public ComponentGroup<Handler<?>> getHandlers()
-
getComponents
public ComponentGroup getComponents()
-
addComponent
public final void addComponent(Component c)
-
addSimpleComponent
public final void addSimpleComponent(java.lang.String idSpec, java.lang.String classSpec, java.lang.String bundleSpec)
-
addHandler
public final void addHandler(Handler h)
-
setHostResponseHeaderKey
public void setHostResponseHeaderKey(java.util.Optional<java.lang.String> hostResponseheaderKey)
If present, this container should emit this header key with the value set to the local hostname in HTTP responses
-
getHttp
public Http getHttp()
-
getDefaultHttpServer
public JettyHttpServer getDefaultHttpServer()
-
getHttpServer
public JettyHttpServer getHttpServer()
-
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
public void initService(com.yahoo.config.application.api.DeployLogger deployLogger)
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
public final java.lang.String 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
public void setClusterName(java.lang.String name)
-
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 Qrserver or 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
public void allocatePorts(int start, PortAllocBridge from)
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)
.
-
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
- Returns:
- portnumber
-
getStartupCommand
public java.lang.String 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 null by default.- Specified by:
getStartupCommand
in interfaceService
- Overrides:
getStartupCommand
in classAbstractService
- Returns:
- null by default.
-
getConfig
public void getConfig(com.yahoo.container.QrConfig.Builder builder)
- Specified by:
getConfig
in interfacecom.yahoo.container.QrConfig.Producer
-
getAssignedJvmOptions
public java.lang.String 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
public java.util.HashMap<java.lang.String,java.lang.String> 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
-
-