Search in sources :

Example 1 with ConfigKeyInfo

use of org.apache.kafka.connect.runtime.rest.entities.ConfigKeyInfo in project kafka by apache.

the class AbstractHerder method convertConfigKey.

private static ConfigKeyInfo convertConfigKey(ConfigKey configKey) {
    String name = configKey.name;
    Type type = configKey.type;
    String typeName = configKey.type.name();
    boolean required = false;
    String defaultValue;
    if (configKey.defaultValue == ConfigDef.NO_DEFAULT_VALUE) {
        defaultValue = (String) configKey.defaultValue;
        required = true;
    } else {
        defaultValue = ConfigDef.convertToString(configKey.defaultValue, type);
    }
    String importance = configKey.importance.name();
    String documentation = configKey.documentation;
    String group = configKey.group;
    int orderInGroup = configKey.orderInGroup;
    String width = configKey.width.name();
    String displayName = configKey.displayName;
    List<String> dependents = configKey.dependents;
    return new ConfigKeyInfo(name, typeName, required, defaultValue, importance, documentation, group, orderInGroup, width, displayName, dependents);
}
Also used : Type(org.apache.kafka.common.config.ConfigDef.Type) ConfigKeyInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigKeyInfo)

Example 2 with ConfigKeyInfo

use of org.apache.kafka.connect.runtime.rest.entities.ConfigKeyInfo in project kafka by apache.

the class AbstractHerder method generateResult.

// public for testing
public static ConfigInfos generateResult(String connType, Map<String, ConfigKey> configKeys, List<ConfigValue> configValues, List<String> groups) {
    int errorCount = 0;
    List<ConfigInfo> configInfoList = new LinkedList<>();
    Map<String, ConfigValue> configValueMap = new HashMap<>();
    for (ConfigValue configValue : configValues) {
        String configName = configValue.name();
        configValueMap.put(configName, configValue);
        if (!configKeys.containsKey(configName)) {
            configValue.addErrorMessage("Configuration is not defined: " + configName);
            configInfoList.add(new ConfigInfo(null, convertConfigValue(configValue, null)));
        }
    }
    for (Map.Entry<String, ConfigKey> entry : configKeys.entrySet()) {
        String configName = entry.getKey();
        ConfigKeyInfo configKeyInfo = convertConfigKey(entry.getValue());
        Type type = entry.getValue().type;
        ConfigValueInfo configValueInfo = null;
        if (configValueMap.containsKey(configName)) {
            ConfigValue configValue = configValueMap.get(configName);
            configValueInfo = convertConfigValue(configValue, type);
            errorCount += configValue.errorMessages().size();
        }
        configInfoList.add(new ConfigInfo(configKeyInfo, configValueInfo));
    }
    return new ConfigInfos(connType, errorCount, groups, configInfoList);
}
Also used : ConfigValue(org.apache.kafka.common.config.ConfigValue) ConfigKey(org.apache.kafka.common.config.ConfigDef.ConfigKey) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConfigInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigInfo) LinkedList(java.util.LinkedList) Type(org.apache.kafka.common.config.ConfigDef.Type) ConfigValueInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigValueInfo) ConfigKeyInfo(org.apache.kafka.connect.runtime.rest.entities.ConfigKeyInfo) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConfigInfos(org.apache.kafka.connect.runtime.rest.entities.ConfigInfos)

Aggregations

Type (org.apache.kafka.common.config.ConfigDef.Type)2 ConfigKeyInfo (org.apache.kafka.connect.runtime.rest.entities.ConfigKeyInfo)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConfigKey (org.apache.kafka.common.config.ConfigDef.ConfigKey)1 ConfigValue (org.apache.kafka.common.config.ConfigValue)1 ConfigInfo (org.apache.kafka.connect.runtime.rest.entities.ConfigInfo)1 ConfigInfos (org.apache.kafka.connect.runtime.rest.entities.ConfigInfos)1 ConfigValueInfo (org.apache.kafka.connect.runtime.rest.entities.ConfigValueInfo)1