use of org.apache.phoenix.flume.serializer.EventSerializers in project phoenix by apache.
the class PhoenixConsumer method initializeSerializer.
/**
* Initializes the serializer for kafka messages.
* @param context
* @param eventSerializerType
*/
private void initializeSerializer(final Context context, final String eventSerializerType) {
String serializerClazz = null;
EventSerializers eventSerializer = null;
try {
eventSerializer = EventSerializers.valueOf(eventSerializerType.toUpperCase());
} catch (IllegalArgumentException iae) {
serializerClazz = eventSerializerType;
}
final Context serializerContext = new Context();
serializerContext.putAll(context.getSubProperties(FlumeConstants.CONFIG_SERIALIZER_PREFIX));
copyPropertiesToSerializerContext(context, serializerContext);
try {
@SuppressWarnings("unchecked") Class<? extends EventSerializer> clazz = null;
if (serializerClazz == null) {
clazz = (Class<? extends EventSerializer>) Class.forName(eventSerializer.getClassName());
} else {
clazz = (Class<? extends EventSerializer>) Class.forName(serializerClazz);
}
serializer = clazz.newInstance();
serializer.configure(serializerContext);
} catch (Exception e) {
logger.error("Could not instantiate event serializer.", e);
Throwables.propagate(e);
}
}
use of org.apache.phoenix.flume.serializer.EventSerializers in project phoenix by apache.
the class PhoenixSink method initializeSerializer.
/**
* Initializes the serializer for flume events.
* @param eventSerializerType
*/
private void initializeSerializer(final Context context, final String eventSerializerType) {
String serializerClazz = null;
EventSerializers eventSerializer = null;
try {
eventSerializer = EventSerializers.valueOf(eventSerializerType.toUpperCase());
} catch (IllegalArgumentException iae) {
serializerClazz = eventSerializerType;
}
final Context serializerContext = new Context();
serializerContext.putAll(context.getSubProperties(FlumeConstants.CONFIG_SERIALIZER_PREFIX));
copyPropertiesToSerializerContext(context, serializerContext);
try {
@SuppressWarnings("unchecked") Class<? extends EventSerializer> clazz = null;
if (serializerClazz == null) {
clazz = (Class<? extends EventSerializer>) Class.forName(eventSerializer.getClassName());
} else {
clazz = (Class<? extends EventSerializer>) Class.forName(serializerClazz);
}
serializer = clazz.newInstance();
serializer.configure(serializerContext);
} catch (Exception e) {
logger.error("Could not instantiate event serializer.", e);
Throwables.propagate(e);
}
}
Aggregations