*/
@SuppressWarnings("unchecked")
public static SinkProcessor getProcessor(Context context,
List<Sink> sinks) {
Map<String, String> params = context.getParameters();
SinkProcessor processor;
String typeStr = (String) params.get(TYPE);
SinkProcessorType type = SinkProcessorType.DEFAULT;
try {
type = SinkProcessorType.valueOf(typeStr.toUpperCase());
} catch (Exception ex) {
logger.warn("Sink type {} does not exist, using default", typeStr);
}
Class<? extends SinkProcessor> processorClass = null;
try {
processorClass = (Class<? extends SinkProcessor>) Class.forName(
type.getSinkProcessorClassName());
} catch (Exception ex) {
throw new FlumeException("Unable to load sink processor type: " + typeStr
+ ", class: " + type.getSinkProcessorClassName(), ex);
}
try {
processor = processorClass.newInstance();
} catch (Exception e) {
throw new FlumeException("Unable to create processor, type: " + typeStr
+ ", class: " + type.getSinkProcessorClassName(), e);
}
processor.setSinks(sinks);
processor.configure(context);
return processor;
}