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, 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 Details

    • BASEPORT

      public static final int BASEPORT
    • SINGLENODE_CONTAINER_SERVICESPEC

      public static final String SINGLENODE_CONTAINER_SERVICESPEC
      See Also:
    • parent

      protected final AbstractConfigProducer<?> parent
    • allocatedSearchPort

      protected int allocatedSearchPort
    • allocatedRpcPort

      protected int allocatedRpcPort
    • allocatedMessagingPort

      protected int allocatedMessagingPort
  • Constructor Details

  • 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

      public ComponentGroup<Handler> getHandlers()
    • getComponents

      public ComponentGroup<?> getComponents()
    • addComponent

      public final void addComponent(Component c)
    • addSimpleComponent

      public final void addSimpleComponent(String idSpec, String classSpec, String bundleSpec)
    • addHandler

      public final void addHandler(Handler h)
    • setHostResponseHeaderKey

      public void setHostResponseHeaderKey(Optional<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()
    • 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(DeployState deployState)
      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
    • getServiceType

      public final String getServiceType()
      Subclasses must implement myServiceType() for a custom service name.
      Specified by:
      getServiceType in interface NetworkPortRequestor
      Overrides:
      getServiceType 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(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
    • requiresWantedPort

      public boolean requiresWantedPort()
      First container must run on ports familiar to the user.
      Specified by:
      requiresWantedPort in interface NetworkPortRequestor
      Overrides:
      requiresWantedPort in class AbstractService
      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 interface NetworkPortRequestor
      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 interface NetworkPortRequestor
    • getSearchPort

      public int getSearchPort()
      Returns:
      the actual search port TODO: Remove. Use AbstractService.getPortsMeta() and check tags in conjunction with AbstractService.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 interface Service
      Overrides:
      getHealthPort in class AbstractService
    • getStartupCommand

      public Optional<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 empty by default.
      Specified by:
      getStartupCommand in interface Service
      Overrides:
      getStartupCommand in class AbstractService
      Returns:
      empty by default.
    • getConfig

      public void getConfig(com.yahoo.container.QrConfig.Builder builder)
      Specified by:
      getConfig in interface com.yahoo.container.QrConfig.Producer
    • getAssignedJvmOptions

      public 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
    • getDefaultMetricDimensions

      public HashMap<String,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 interface Service
      Overrides:
      getDefaultMetricDimensions in class AbstractService
      Returns:
      the default dimensions for this service
    • containerCluster

      protected Optional<ContainerCluster> containerCluster()