Package com.yahoo.config.model.producer
Class AbstractConfigProducer<CHILD extends AbstractConfigProducer<?>>
- java.lang.Object
-
- com.yahoo.config.model.producer.AbstractConfigProducer<CHILD>
-
- All Implemented Interfaces:
com.yahoo.config.ConfigInstance.Producer
,ConfigProducer
,java.io.Serializable
- Direct Known Subclasses:
AbstractConfigProducerRoot
,AbstractSearchCluster
,AbstractService
,Admin
,ApplicationConfigProducerRoot
,Chain
,Chains
,Client
,ClusterControllerCluster
,ClusterControllerConfig
,Component
,ConfigProducerGroup
,ConfigserverCluster
,ContainerCluster
,ContentCluster
,ContentSearchCluster
,DistributorCluster
,DocumentDatabase
,FileDistributionConfigProducer
,FileDistributionConfigProvider
,Host
,HostSystem
,Http
,IndexedSearchCluster.UnionConfiguration
,ModelConfigProvider
,Module
,PersistenceEngine
,RestApi
,ServiceCluster
,SimpleConfigProducer
,StorageCluster
,Tuning
public abstract class AbstractConfigProducer<CHILD extends AbstractConfigProducer<?>> extends java.lang.Object implements ConfigProducer, com.yahoo.config.ConfigInstance.Producer, java.io.Serializable
Superclass for all config producers. Config producers constructs and returns config instances on request.- Author:
- gjoranv
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.logging.Logger
log
-
Constructor Summary
Constructors Constructor Description AbstractConfigProducer(AbstractConfigProducer parent, java.lang.String subId)
Creates a new AbstractConfigProducer with the given parent and subId.AbstractConfigProducer(java.lang.String subId)
Create an config producer with a configId only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addChild(CHILD child)
Adds a child to this config producer.protected void
addConfigId(java.lang.String id)
Sets the config id for this producer.protected void
addDescendantService(Service s)
boolean
addUserConfig(com.yahoo.config.ConfigInstance.Builder builder)
Adds user config override from this ConfigProducer to the existing builderboolean
cascadeConfig(com.yahoo.config.ConfigInstance.Builder builder)
Build config from this and all parent ConfigProducers, such that the root node's config will be added first, and this ConfigProducer's config last in the returned builder.void
dump(java.io.PrintStream out)
Dump the three of config producers to the specified stream.java.util.Map<java.lang.String,CHILD>
getChildren()
Returns this ConfigProducer's children (only 1st level)<J extends AbstractConfigProducer<?>>
java.util.List<J>getChildrenByTypeRecursive(java.lang.Class<J> type)
protected java.lang.ClassLoader
getConfigClassLoader(java.lang.String producerName)
java.lang.String
getConfigId()
ConfigProducers that must have a special config id should use setConfigId() instead of overloading this method.java.util.List<Service>
getDescendantServices()
Returns a list of all the children of this who are instances of Serviceprotected Monitoring
getMonitoringService()
Returns a monitoring service if configured, null otherwiseAbstractConfigProducer
getParent()
AbstractConfigProducerRoot
getRoot()
java.lang.String
getSubId()
UserConfigRepo
getUserConfigs()
Returns the user configs of thisHostSystem
hostSystem()
Returns the one and only HostSystem of the root node.void
mergeUserConfigs(UserConfigRepo newRepo)
void
removeChild(CHILD child)
protected void
setParent(AbstractConfigProducer parent)
void
setUserConfigs(UserConfigRepo repo)
Sets the user configs for this producer.protected static boolean
stateIsHosted(DeployState deployState)
void
validate()
check constraints depending on the state of the vespamodel graph.
-
-
-
Constructor Detail
-
AbstractConfigProducer
public AbstractConfigProducer(AbstractConfigProducer parent, java.lang.String subId)
Creates a new AbstractConfigProducer with the given parent and subId. This constructor will add the resulting producer to the children of parent.- Parameters:
parent
- The parent of this ConfigProducersubId
- The fragment of the config id for the producer
-
AbstractConfigProducer
public AbstractConfigProducer(java.lang.String subId)
Create an config producer with a configId only. Used e.g. to create root nodes, and producers that are given children after construction usingaddChild(AbstractConfigProducer)
.- Parameters:
subId
- The sub configId. Note that this can be prefixed when calling addChild with this producer as arg.
-
-
Method Detail
-
stateIsHosted
protected static boolean stateIsHosted(DeployState deployState)
-
setParent
protected final void setParent(AbstractConfigProducer parent)
-
getSubId
public final java.lang.String getSubId()
-
addChild
protected void addChild(CHILD child)
Adds a child to this config producer.- Parameters:
child
- The child config producer to add.
-
removeChild
public void removeChild(CHILD child)
-
setUserConfigs
public void setUserConfigs(UserConfigRepo repo)
Sets the user configs for this producer.- Parameters:
repo
- User configs repo.
-
getUserConfigs
public UserConfigRepo getUserConfigs()
Returns the user configs of this- Specified by:
getUserConfigs
in interfaceConfigProducer
-
getConfigId
public final java.lang.String getConfigId()
ConfigProducers that must have a special config id should use setConfigId() instead of overloading this method. This is because config IDs must be registered through setConfigId().- Specified by:
getConfigId
in interfaceConfigProducer
-
addConfigId
protected void addConfigId(java.lang.String id)
Sets the config id for this producer. Will also add this service to the root node, so the new config id will be picked up. Note that this producer will be known with both the old and the new config id in the root node after using this method.
-
getChildren
public java.util.Map<java.lang.String,CHILD> getChildren()
Returns this ConfigProducer's children (only 1st level)- Specified by:
getChildren
in interfaceConfigProducer
-
getChildrenByTypeRecursive
@Beta public <J extends AbstractConfigProducer<?>> java.util.List<J> getChildrenByTypeRecursive(java.lang.Class<J> type)
-
getDescendantServices
public java.util.List<Service> getDescendantServices()
Returns a list of all the children of this who are instances of Service- Specified by:
getDescendantServices
in interfaceConfigProducer
-
addDescendantService
protected void addDescendantService(Service s)
-
cascadeConfig
public final boolean cascadeConfig(com.yahoo.config.ConfigInstance.Builder builder)
Description copied from interface:ConfigProducer
Build config from this and all parent ConfigProducers, such that the root node's config will be added first, and this ConfigProducer's config last in the returned builder.- Specified by:
cascadeConfig
in interfaceConfigProducer
- Parameters:
builder
- The builder implemented by the concrete ConfigInstance class- Returns:
- true if a model config producer was found, so config was applied
-
addUserConfig
public final boolean addUserConfig(com.yahoo.config.ConfigInstance.Builder builder)
Description copied from interface:ConfigProducer
Adds user config override from this ConfigProducer to the existing builder- Specified by:
addUserConfig
in interfaceConfigProducer
- Parameters:
builder
- The ConfigBuilder to add user config overrides.- Returns:
- true if overrides were added, false if not.
-
hostSystem
public HostSystem hostSystem()
Returns the one and only HostSystem of the root node. Must be overridden by root node.- Specified by:
hostSystem
in interfaceConfigProducer
-
getRoot
public AbstractConfigProducerRoot getRoot()
-
getParent
public AbstractConfigProducer getParent()
-
dump
public void dump(java.io.PrintStream out)
Description copied from interface:ConfigProducer
Dump the three of config producers to the specified stream.- Specified by:
dump
in interfaceConfigProducer
- Parameters:
out
- The stream to print to, e.g. System.out
-
getConfigClassLoader
protected java.lang.ClassLoader getConfigClassLoader(java.lang.String producerName)
-
mergeUserConfigs
public void mergeUserConfigs(UserConfigRepo newRepo)
-
validate
public void validate() throws java.lang.Exception
Description copied from interface:ConfigProducer
check constraints depending on the state of the vespamodel graph. When overriding, you must invoke super.- Specified by:
validate
in interfaceConfigProducer
- Throws:
java.lang.Exception
-
getMonitoringService
protected Monitoring getMonitoringService()
Returns a monitoring service if configured, null otherwise
-
-