use of org.apache.apex.malhar.lib.io.fs.TailFsInputOperator in project apex-malhar by apache.
the class ApplicationLocalLog method populateDAG.
@Override
public void populateDAG(DAG dag, Configuration conf) {
TailFsInputOperator log = dag.addOperator("log", new TailFsInputOperator());
log.setDelimiter('\n');
log.setFilePath("/var/log/apache2/access.log");
ApacheLogParseMapOutputOperator parse = dag.addOperator("parse", new ApacheLogParseMapOutputOperator());
GeoIPExtractor geoIPExtractor = new GeoIPExtractor();
// Can't put this file in resources until licensing issue is straightened out
geoIPExtractor.setDatabasePath("/home/david/GeoLiteCity.dat");
parse.registerInformationExtractor("ip", geoIPExtractor);
parse.registerInformationExtractor("agent", new UserAgentExtractor());
TimestampExtractor timestampExtractor = new TimestampExtractor();
timestampExtractor.setDateFormatString("dd/MMM/yyyy:HH:mm:ss Z");
parse.registerInformationExtractor("time", timestampExtractor);
ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
dag.addStream("log-parse", log.output, parse.data);
dag.addStream("parse-console", parse.output, console.input).setLocality(Locality.CONTAINER_LOCAL);
}
Aggregations