Search in sources :

Example 1 with ImportStrategy

use of org.apache.metron.dataloads.nonbulk.flatfile.importer.ImportStrategy in project metron by apache.

the class SimpleEnrichmentFlatFileLoader method main.

public static void main(Configuration hadoopConfig, String[] argv) throws Exception {
    CommandLine cli = LoadOptions.parse(new PosixParser(), argv);
    EnumMap<LoadOptions, Optional<Object>> config = LoadOptions.createConfig(cli);
    if (LoadOptions.LOG4J_PROPERTIES.has(cli)) {
        PropertyConfigurator.configure(LoadOptions.LOG4J_PROPERTIES.get(cli));
    }
    ExtractorHandler handler = ExtractorHandler.load(FileUtils.readFileToString(new File(LoadOptions.EXTRACTOR_CONFIG.get(cli).trim())));
    ImportStrategy strategy = (ImportStrategy) config.get(LoadOptions.IMPORT_MODE).get();
    strategy.getImporter().importData(config, handler, hadoopConfig);
    SensorEnrichmentUpdateConfig sensorEnrichmentUpdateConfig = null;
    if (LoadOptions.ENRICHMENT_CONFIG.has(cli)) {
        sensorEnrichmentUpdateConfig = JSONUtils.INSTANCE.load(new File(LoadOptions.ENRICHMENT_CONFIG.get(cli)), SensorEnrichmentUpdateConfig.class);
    }
    if (sensorEnrichmentUpdateConfig != null) {
        sensorEnrichmentUpdateConfig.updateSensorConfigs();
    }
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) ImportStrategy(org.apache.metron.dataloads.nonbulk.flatfile.importer.ImportStrategy) Optional(java.util.Optional) ExtractorHandler(org.apache.metron.dataloads.extractor.ExtractorHandler) PosixParser(org.apache.commons.cli.PosixParser) SensorEnrichmentUpdateConfig(org.apache.metron.common.configuration.enrichment.SensorEnrichmentUpdateConfig) File(java.io.File)

Aggregations

File (java.io.File)1 Optional (java.util.Optional)1 CommandLine (org.apache.commons.cli.CommandLine)1 PosixParser (org.apache.commons.cli.PosixParser)1 SensorEnrichmentUpdateConfig (org.apache.metron.common.configuration.enrichment.SensorEnrichmentUpdateConfig)1 ExtractorHandler (org.apache.metron.dataloads.extractor.ExtractorHandler)1 ImportStrategy (org.apache.metron.dataloads.nonbulk.flatfile.importer.ImportStrategy)1