use of org.apache.metron.parsers.bolt.WriterHandler in project metron by apache.
the class ParserTopologyBuilder method createErrorBolt.
/**
* Create a bolt that handles error messages.
*
* @param zookeeperUrl Kafka zookeeper URL
* @param brokerUrl Kafka Broker URL
* @param sensorType Type of sensor that is being consumed.
* @param securityProtocol Security protocol used (if any)
* @param configs
* @param parserConfig
* @return A Storm bolt that handles error messages.
*/
private static WriterBolt createErrorBolt(String zookeeperUrl, Optional<String> brokerUrl, String sensorType, Optional<String> securityProtocol, ParserConfigurations configs, SensorParserConfig parserConfig) {
// create writer - if not configured uses a sensible default
AbstractWriter writer = parserConfig.getErrorWriterClassName() == null ? createKafkaWriter(brokerUrl, zookeeperUrl, securityProtocol).withTopic((String) configs.getGlobalConfig().get("parser.error.topic")).withConfigPrefix("error") : ReflectionUtils.createInstance(parserConfig.getWriterClassName());
writer.configure(sensorType, new ParserWriterConfiguration(configs));
// create a writer handler
WriterHandler writerHandler = createWriterHandler(writer);
return new WriterBolt(writerHandler, configs, sensorType).withErrorType(Constants.ErrorType.PARSER_ERROR);
}
use of org.apache.metron.parsers.bolt.WriterHandler in project metron by apache.
the class ParserTopologyBuilder method createParserBolt.
/**
* Create a bolt that parses input from a sensor.
*
* @param zookeeperUrl Zookeeper URL
* @param brokerUrl Kafka Broker URL
* @param sensorType Type of sensor that is being consumed.
* @param configs
* @param parserConfig
* @return A Storm bolt that parses input from a sensor
*/
private static ParserBolt createParserBolt(String zookeeperUrl, Optional<String> brokerUrl, String sensorType, Optional<String> securityProtocol, ParserConfigurations configs, SensorParserConfig parserConfig, Optional<String> outputTopic) {
// create message parser
MessageParser<JSONObject> parser = ReflectionUtils.createInstance(parserConfig.getParserClassName());
parser.configure(parserConfig.getParserConfig());
// create writer - if not configured uses a sensible default
AbstractWriter writer = parserConfig.getWriterClassName() == null ? createKafkaWriter(brokerUrl, zookeeperUrl, securityProtocol).withTopic(outputTopic.orElse(Constants.ENRICHMENT_TOPIC)) : ReflectionUtils.createInstance(parserConfig.getWriterClassName());
writer.configure(sensorType, new ParserWriterConfiguration(configs));
// create a writer handler
WriterHandler writerHandler = createWriterHandler(writer);
return new ParserBolt(zookeeperUrl, sensorType, parser, writerHandler);
}
Aggregations