use of org.apache.kafka.common.serialization.Serde in project apache-kafka-on-k8s by banzaicloud.
the class SessionWindowedSerializer method configure.
@SuppressWarnings("unchecked")
@Override
public void configure(final Map<String, ?> configs, final boolean isKey) {
if (inner == null) {
String propertyName = isKey ? StreamsConfig.DEFAULT_WINDOWED_KEY_SERDE_INNER_CLASS : StreamsConfig.DEFAULT_WINDOWED_VALUE_SERDE_INNER_CLASS;
String value = (String) configs.get(propertyName);
try {
inner = Serde.class.cast(Utils.newInstance(value, Serde.class)).serializer();
inner.configure(configs, isKey);
} catch (final ClassNotFoundException e) {
throw new ConfigException(propertyName, value, "Serde class " + value + " could not be found.");
}
}
}
use of org.apache.kafka.common.serialization.Serde in project apache-kafka-on-k8s by banzaicloud.
the class TimeWindowedSerializer method configure.
@SuppressWarnings("unchecked")
@Override
public void configure(final Map<String, ?> configs, final boolean isKey) {
if (inner == null) {
final String propertyName = isKey ? StreamsConfig.DEFAULT_WINDOWED_KEY_SERDE_INNER_CLASS : StreamsConfig.DEFAULT_WINDOWED_VALUE_SERDE_INNER_CLASS;
final String value = (String) configs.get(propertyName);
try {
inner = Serde.class.cast(Utils.newInstance(value, Serde.class)).serializer();
inner.configure(configs, isKey);
} catch (final ClassNotFoundException e) {
throw new ConfigException(propertyName, value, "Serde class " + value + " could not be found.");
}
}
}
use of org.apache.kafka.common.serialization.Serde in project apache-kafka-on-k8s by banzaicloud.
the class StreamsConfig method defaultValueSerde.
/**
* Return an {@link Serde#configure(Map, boolean) configured} instance of {@link #DEFAULT_VALUE_SERDE_CLASS_CONFIG value
* Serde class}.
*
* @return an configured instance of value Serde class
*/
public Serde defaultValueSerde() {
Object valueSerdeConfigSetting = get(VALUE_SERDE_CLASS_CONFIG);
try {
Serde<?> serde = getConfiguredInstance(VALUE_SERDE_CLASS_CONFIG, Serde.class);
if (serde == null) {
valueSerdeConfigSetting = get(DEFAULT_VALUE_SERDE_CLASS_CONFIG);
serde = getConfiguredInstance(DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serde.class);
}
serde.configure(originals(), false);
return serde;
} catch (final Exception e) {
throw new StreamsException(String.format("Failed to configure value serde %s", valueSerdeConfigSetting), e);
}
}
use of org.apache.kafka.common.serialization.Serde in project apache-kafka-on-k8s by banzaicloud.
the class StreamsConfig method defaultKeySerde.
/**
* Return an {@link Serde#configure(Map, boolean) configured} instance of {@link #DEFAULT_KEY_SERDE_CLASS_CONFIG key Serde
* class}.
*
* @return an configured instance of key Serde class
*/
public Serde defaultKeySerde() {
Object keySerdeConfigSetting = get(KEY_SERDE_CLASS_CONFIG);
try {
Serde<?> serde = getConfiguredInstance(KEY_SERDE_CLASS_CONFIG, Serde.class);
if (serde == null) {
keySerdeConfigSetting = get(DEFAULT_KEY_SERDE_CLASS_CONFIG);
serde = getConfiguredInstance(DEFAULT_KEY_SERDE_CLASS_CONFIG, Serde.class);
}
serde.configure(originals(), true);
return serde;
} catch (final Exception e) {
throw new StreamsException(String.format("Failed to configure key serde %s", keySerdeConfigSetting), e);
}
}
use of org.apache.kafka.common.serialization.Serde in project apache-kafka-on-k8s by banzaicloud.
the class SessionWindowedDeserializer method configure.
@SuppressWarnings("unchecked")
@Override
public void configure(final Map<String, ?> configs, final boolean isKey) {
if (inner == null) {
final String propertyName = isKey ? StreamsConfig.DEFAULT_WINDOWED_KEY_SERDE_INNER_CLASS : StreamsConfig.DEFAULT_WINDOWED_VALUE_SERDE_INNER_CLASS;
final String value = (String) configs.get(propertyName);
try {
inner = Serde.class.cast(Utils.newInstance(value, Serde.class)).deserializer();
inner.configure(configs, isKey);
} catch (final ClassNotFoundException e) {
throw new ConfigException(propertyName, value, "Serde class " + value + " could not be found.");
}
}
}
Aggregations