Class 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 Detail

      • BASEPORT

        public static final int BASEPORT
      • SINGLENODE_CONTAINER_SERVICESPEC

        public static final java.lang.String SINGLENODE_CONTAINER_SERVICESPEC
        See Also:
        Constant Field Values
      • allocatedSearchPort

        protected int allocatedSearchPort
      • allocatedRpcPort

        protected int allocatedRpcPort
      • allocatedMessagingPort

        protected int allocatedMessagingPort
    • Constructor Detail

      • 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)
      • 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()
      • 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 class AbstractService
      • 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 interface NetworkPortRequestor
        Overrides:
        getWantedPort in class AbstractService
        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
      • 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 interface NetworkPortRequestor
        Returns:
        the number of ports needed by the Container
      • numRpcPorts

        protected int numRpcPorts()
      • numMessageBusPorts

        protected int numMessageBusPorts()
      • 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 interface Service
        Overrides:
        getStartupCommand in class AbstractService
        Returns:
        null by default.
      • getConfig

        public void getConfig​(com.yahoo.container.QrConfig.Builder builder)
        Specified by:
        getConfig in interface com.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 interface com.yahoo.container.ComponentsConfig.Producer
      • getConfig

        public final void getConfig​(com.yahoo.container.jdisc.JdiscBindingsConfig.Builder builder)
        Specified by:
        getConfig in interface com.yahoo.container.jdisc.JdiscBindingsConfig.Producer
      • getConfig

        public void getConfig​(com.yahoo.container.core.ContainerHttpConfig.Builder builder)
        Specified by:
        getConfig in interface com.yahoo.container.core.ContainerHttpConfig.Producer
      • getConfig

        public void getConfig​(com.yahoo.container.jdisc.ContainerMbusConfig.Builder builder)
        Specified by:
        getConfig in interface com.yahoo.container.jdisc.ContainerMbusConfig.Producer