Search in sources :

Example 1 with SimpleConfig

use of org.apache.kafka.connect.transforms.util.SimpleConfig in project kafka by apache.

the class TimestampRouter method configure.

@Override
public void configure(Map<String, ?> props) {
    final SimpleConfig config = new SimpleConfig(CONFIG_DEF, props);
    topicFormat = config.getString(ConfigName.TOPIC_FORMAT);
    final String timestampFormatStr = config.getString(ConfigName.TIMESTAMP_FORMAT);
    timestampFormat = new ThreadLocal<SimpleDateFormat>() {

        @Override
        protected SimpleDateFormat initialValue() {
            final SimpleDateFormat fmt = new SimpleDateFormat(timestampFormatStr);
            fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
            return fmt;
        }
    };
}
Also used : SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with SimpleConfig

use of org.apache.kafka.connect.transforms.util.SimpleConfig in project kafka by apache.

the class ValueToKey method configure.

@Override
public void configure(Map<String, ?> configs) {
    final SimpleConfig config = new SimpleConfig(CONFIG_DEF, configs);
    fields = config.getList(FIELDS_CONFIG);
    valueToKeySchemaCache = new SynchronizedCache<>(new LRUCache<Schema, Schema>(16));
}
Also used : SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig) LRUCache(org.apache.kafka.common.cache.LRUCache)

Example 3 with SimpleConfig

use of org.apache.kafka.connect.transforms.util.SimpleConfig in project kafka by apache.

the class ExtractField method configure.

@Override
public void configure(Map<String, ?> props) {
    final SimpleConfig config = new SimpleConfig(CONFIG_DEF, props);
    fieldName = config.getString(FIELD_CONFIG);
}
Also used : SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig)

Example 4 with SimpleConfig

use of org.apache.kafka.connect.transforms.util.SimpleConfig in project kafka by apache.

the class InsertField method configure.

@Override
public void configure(Map<String, ?> props) {
    final SimpleConfig config = new SimpleConfig(CONFIG_DEF, props);
    topicField = InsertionSpec.parse(config.getString(ConfigName.TOPIC_FIELD));
    partitionField = InsertionSpec.parse(config.getString(ConfigName.PARTITION_FIELD));
    offsetField = InsertionSpec.parse(config.getString(ConfigName.OFFSET_FIELD));
    timestampField = InsertionSpec.parse(config.getString(ConfigName.TIMESTAMP_FIELD));
    staticField = InsertionSpec.parse(config.getString(ConfigName.STATIC_FIELD));
    staticValue = config.getString(ConfigName.STATIC_VALUE);
    if (topicField == null && partitionField == null && offsetField == null && timestampField == null && staticField == null) {
        throw new ConfigException("No field insertion configured");
    }
    if (staticField != null && staticValue == null) {
        throw new ConfigException(ConfigName.STATIC_VALUE, null, "No value specified for static field: " + staticField);
    }
    schemaUpdateCache = new SynchronizedCache<>(new LRUCache<Schema, Schema>(16));
}
Also used : SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig) LRUCache(org.apache.kafka.common.cache.LRUCache) ConfigException(org.apache.kafka.common.config.ConfigException)

Example 5 with SimpleConfig

use of org.apache.kafka.connect.transforms.util.SimpleConfig in project kafka by apache.

the class RegexRouter method configure.

@Override
public void configure(Map<String, ?> props) {
    final SimpleConfig config = new SimpleConfig(CONFIG_DEF, props);
    regex = Pattern.compile(config.getString(ConfigName.REGEX));
    replacement = config.getString(ConfigName.REPLACEMENT);
}
Also used : SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig)

Aggregations

SimpleConfig (org.apache.kafka.connect.transforms.util.SimpleConfig)9 LRUCache (org.apache.kafka.common.cache.LRUCache)4 ConfigException (org.apache.kafka.common.config.ConfigException)2 SimpleDateFormat (java.text.SimpleDateFormat)1