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));
}
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);
}
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));
}
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));
}
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));
}
Aggregations