Search in sources :

Example 1 with ConfigInfo

use of org.apache.kafka.connect.runtime.rest.entities.ConfigInfo 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

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 Type (org.apache.kafka.common.config.ConfigDef.Type)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 ConfigKeyInfo (org.apache.kafka.connect.runtime.rest.entities.ConfigKeyInfo)1 ConfigValueInfo (org.apache.kafka.connect.runtime.rest.entities.ConfigValueInfo)1