Search in sources :

Example 1 with LRUCache

use of org.apache.kafka.common.cache.LRUCache in project apache-kafka-on-k8s by banzaicloud.

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 2 with LRUCache

use of org.apache.kafka.common.cache.LRUCache in project apache-kafka-on-k8s by banzaicloud.

the class TimestampConverter method configure.

@Override
public void configure(Map<String, ?> configs) {
    final SimpleConfig simpleConfig = new SimpleConfig(CONFIG_DEF, configs);
    final String field = simpleConfig.getString(FIELD_CONFIG);
    final String type = simpleConfig.getString(TARGET_TYPE_CONFIG);
    String formatPattern = simpleConfig.getString(FORMAT_CONFIG);
    schemaUpdateCache = new SynchronizedCache<>(new LRUCache<Schema, Schema>(16));
    if (!VALID_TYPES.contains(type)) {
        throw new ConfigException("Unknown timestamp type in TimestampConverter: " + type + ". Valid values are " + Utils.join(VALID_TYPES, ", ") + ".");
    }
    if (type.equals(TYPE_STRING) && formatPattern.trim().isEmpty()) {
        throw new ConfigException("TimestampConverter requires format option to be specified when using string timestamps");
    }
    SimpleDateFormat format = null;
    if (formatPattern != null && !formatPattern.trim().isEmpty()) {
        try {
            format = new SimpleDateFormat(formatPattern);
            format.setTimeZone(UTC);
        } catch (IllegalArgumentException e) {
            throw new ConfigException("TimestampConverter requires a SimpleDateFormat-compatible pattern for string timestamps: " + formatPattern, e);
        }
    }
    config = new Config(field, type, format);
}
Also used : SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig) LRUCache(org.apache.kafka.common.cache.LRUCache) SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig) ConfigException(org.apache.kafka.common.config.ConfigException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with LRUCache

use of org.apache.kafka.common.cache.LRUCache in project apache-kafka-on-k8s by banzaicloud.

the class HoistField method configure.

@Override
public void configure(Map<String, ?> props) {
    final SimpleConfig config = new SimpleConfig(CONFIG_DEF, props);
    fieldName = config.getString("field");
    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)

Example 4 with LRUCache

use of org.apache.kafka.common.cache.LRUCache in project kafka by apache.

the class Cast method configure.

@Override
public void configure(Map<String, ?> props) {
    final SimpleConfig config = new SimpleConfig(CONFIG_DEF, props);
    casts = parseFieldTypes(config.getList(SPEC_CONFIG));
    wholeValueCastType = casts.get(WHOLE_VALUE_CAST);
    schemaUpdateCache = new SynchronizedCache<>(new LRUCache<>(16));
}
Also used : SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig) LRUCache(org.apache.kafka.common.cache.LRUCache)

Example 5 with LRUCache

use of org.apache.kafka.common.cache.LRUCache in project kafka by apache.

the class ReplaceField method configure.

@Override
public void configure(Map<String, ?> configs) {
    final SimpleConfig config = new SimpleConfig(CONFIG_DEF, ConfigUtils.translateDeprecatedConfigs(configs, new String[][] { { ConfigName.INCLUDE, "whitelist" }, { ConfigName.EXCLUDE, "blacklist" } }));
    exclude = config.getList(ConfigName.EXCLUDE);
    include = config.getList(ConfigName.INCLUDE);
    renames = parseRenameMappings(config.getList(ConfigName.RENAME));
    reverseRenames = invert(renames);
    schemaUpdateCache = new SynchronizedCache<>(new LRUCache<>(16));
}
Also used : SimpleConfig(org.apache.kafka.connect.transforms.util.SimpleConfig) LRUCache(org.apache.kafka.common.cache.LRUCache)

Aggregations

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