|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.kafka.common.config.ConfigDef
public class ConfigDef
This class is used for specifying the set of expected configurations, their type, their defaults, their documentation, and any special validation logic used for checking the correctness of the values the user provides.
Usage of this class looks something like this:
ConfigDef defs = new ConfigDef(); defs.define("config_name", Type.STRING, "default string value", "This configuration is used for blah blah blah."); defs.define("another_config_name", Type.INT, 42, Range.atLeast(0), "More documentation on this config"); Properties props = new Properties(); props.setProperty("config_name", "some value"); Map<String, Object> configs = defs.parse(props); String someConfig = (String) configs.get("config_name"); // will return "some value" int anotherConfig = (Integer) configs.get("another_config_name"); // will return default value of 42This class can be used stand-alone or in combination with
AbstractConfig
which provides some additional
functionality for accessing configs.
Nested Class Summary | |
---|---|
static class |
ConfigDef.Importance
|
static class |
ConfigDef.Range
Validation logic for numeric ranges |
static class |
ConfigDef.Type
The config types |
static interface |
ConfigDef.Validator
Validation logic the user may provide |
static class |
ConfigDef.ValidString
|
Constructor Summary | |
---|---|
ConfigDef()
|
Method Summary | |
---|---|
ConfigDef |
define(java.lang.String name,
ConfigDef.Type type,
ConfigDef.Importance importance,
java.lang.String documentation)
Define a required parameter with no default value and no special validation logic |
ConfigDef |
define(java.lang.String name,
ConfigDef.Type type,
ConfigDef.Validator validator,
ConfigDef.Importance importance,
java.lang.String documentation)
Define a required parameter with no default value |
ConfigDef |
define(java.lang.String name,
ConfigDef.Type type,
java.lang.Object defaultValue,
ConfigDef.Importance importance,
java.lang.String documentation)
Define a new configuration with no special validation logic |
ConfigDef |
define(java.lang.String name,
ConfigDef.Type type,
java.lang.Object defaultValue,
ConfigDef.Validator validator,
ConfigDef.Importance importance,
java.lang.String documentation)
Define a new configuration |
java.util.Map<java.lang.String,java.lang.Object> |
parse(java.util.Map<?,?> props)
Parse and validate configs against this configuration definition. |
java.lang.String |
toHtmlTable()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConfigDef()
Method Detail |
---|
public ConfigDef define(java.lang.String name, ConfigDef.Type type, java.lang.Object defaultValue, ConfigDef.Validator validator, ConfigDef.Importance importance, java.lang.String documentation)
name
- The name of the config parametertype
- The type of the configdefaultValue
- The default value to use if this config isn't presentvalidator
- A validator to use in checking the correctness of the configimportance
- The importance of this config: is this something you will likely need to change.documentation
- The documentation string for the config
public ConfigDef define(java.lang.String name, ConfigDef.Type type, java.lang.Object defaultValue, ConfigDef.Importance importance, java.lang.String documentation)
name
- The name of the config parametertype
- The type of the configdefaultValue
- The default value to use if this config isn't presentimportance
- The importance of this config: is this something you will likely need to change.documentation
- The documentation string for the config
public ConfigDef define(java.lang.String name, ConfigDef.Type type, ConfigDef.Validator validator, ConfigDef.Importance importance, java.lang.String documentation)
name
- The name of the config parametertype
- The type of the configvalidator
- A validator to use in checking the correctness of the configimportance
- The importance of this config: is this something you will likely need to change.documentation
- The documentation string for the config
public ConfigDef define(java.lang.String name, ConfigDef.Type type, ConfigDef.Importance importance, java.lang.String documentation)
name
- The name of the config parametertype
- The type of the configimportance
- The importance of this config: is this something you will likely need to change.documentation
- The documentation string for the config
public java.util.Map<java.lang.String,java.lang.Object> parse(java.util.Map<?,?> props)
props
- The configs to parse and validate
public java.lang.String toHtmlTable()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |