org.apache.kafka.common.config
Class ConfigDef

java.lang.Object
  extended by org.apache.kafka.common.config.ConfigDef

public class ConfigDef
extends java.lang.Object

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 42
 
This 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

ConfigDef

public ConfigDef()
Method Detail

define

public 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

Parameters:
name - The name of the config parameter
type - The type of the config
defaultValue - The default value to use if this config isn't present
validator - A validator to use in checking the correctness of the config
importance - The importance of this config: is this something you will likely need to change.
documentation - The documentation string for the config
Returns:
This ConfigDef so you can chain calls

define

public 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

Parameters:
name - The name of the config parameter
type - The type of the config
defaultValue - The default value to use if this config isn't present
importance - The importance of this config: is this something you will likely need to change.
documentation - The documentation string for the config
Returns:
This ConfigDef so you can chain calls

define

public 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

Parameters:
name - The name of the config parameter
type - The type of the config
validator - A validator to use in checking the correctness of the config
importance - The importance of this config: is this something you will likely need to change.
documentation - The documentation string for the config
Returns:
This ConfigDef so you can chain calls

define

public 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

Parameters:
name - The name of the config parameter
type - The type of the config
importance - The importance of this config: is this something you will likely need to change.
documentation - The documentation string for the config
Returns:
This ConfigDef so you can chain calls

parse

public java.util.Map<java.lang.String,java.lang.Object> parse(java.util.Map<?,?> props)
Parse and validate configs against this configuration definition. The input is a map of configs. It is expected that the keys of the map are strings, but the values can either be strings or they may already be of the appropriate type (int, string, etc). This will work equally well with either java.util.Properties instances or a programmatically constructed map.

Parameters:
props - The configs to parse and validate
Returns:
Parsed and validated configs. The key will be the config name and the value will be the value parsed into the appropriate type (int, string, etc)

toHtmlTable

public java.lang.String toHtmlTable()