use of org.apache.commons.cli.PosixParser 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();
}
}
use of org.apache.commons.cli.PosixParser in project metron by apache.
the class SimpleFlatFileSummarizer method main.
public static void main(Configuration hadoopConfig, String[] argv) throws Exception {
CommandLine cli = SummarizeOptions.parse(new PosixParser(), argv);
EnumMap<SummarizeOptions, Optional<Object>> config = SummarizeOptions.createConfig(cli);
if (SummarizeOptions.LOG4J_PROPERTIES.has(cli)) {
PropertyConfigurator.configure(SummarizeOptions.LOG4J_PROPERTIES.get(cli));
}
ExtractorHandler handler = ExtractorHandler.load(FileUtils.readFileToString(new File(SummarizeOptions.EXTRACTOR_CONFIG.get(cli).trim())));
Summarizers strategy = (Summarizers) config.get(SummarizeOptions.IMPORT_MODE).get();
strategy.getSummarizer().importData(config, handler, hadoopConfig);
}
use of org.apache.commons.cli.PosixParser in project metron by apache.
the class LeastRecentlyUsedPrunerIntegrationTest method testCommandLine.
@Test
public void testCommandLine() throws Exception {
Configuration conf = HBaseConfiguration.create();
String[] argv = { "-a 04/14/2016 12:00:00", "-f cf", "-t malicious_domains", "-u access_trackers", "-v georgia", "-z cf" };
String[] otherArgs = new GenericOptionsParser(conf, argv).getRemainingArgs();
CommandLine cli = LeastRecentlyUsedPruner.BulkLoadOptions.parse(new PosixParser(), otherArgs);
Assert.assertEquals(cf, LeastRecentlyUsedPruner.BulkLoadOptions.COLUMN_FAMILY.get(cli).trim());
Assert.assertEquals(tableName, LeastRecentlyUsedPruner.BulkLoadOptions.TABLE.get(cli).trim());
Assert.assertEquals(atTableName, LeastRecentlyUsedPruner.BulkLoadOptions.ACCESS_TABLE.get(cli).trim());
Assert.assertEquals(atCF, LeastRecentlyUsedPruner.BulkLoadOptions.ACCESS_COLUMN_FAMILY.get(cli).trim());
Assert.assertEquals(beginTime, LeastRecentlyUsedPruner.BulkLoadOptions.AS_OF_TIME.get(cli).trim());
Assert.assertEquals(timeFormat, LeastRecentlyUsedPruner.BulkLoadOptions.AS_OF_TIME_FORMAT.get(cli).trim());
}
use of org.apache.commons.cli.PosixParser in project metron by apache.
the class SimpleEnrichmentFlatFileLoaderIntegrationTest method testArgs.
@Test
public void testArgs() throws Exception {
String[] argv = { "-c cf", "-t enrichment", "-e extractor.json", "-n enrichment_config.json", "-l log4j", "-i input.csv", "-p 2", "-b 128", "-q" };
String[] otherArgs = new GenericOptionsParser(config, argv).getRemainingArgs();
CommandLine cli = LoadOptions.parse(new PosixParser(), otherArgs);
Assert.assertEquals(extractorJson, LoadOptions.EXTRACTOR_CONFIG.get(cli).trim());
Assert.assertEquals(cf, LoadOptions.HBASE_CF.get(cli).trim());
Assert.assertEquals(tableName, LoadOptions.HBASE_TABLE.get(cli).trim());
Assert.assertEquals(enrichmentJson, LoadOptions.ENRICHMENT_CONFIG.get(cli).trim());
Assert.assertEquals(csvFile, LoadOptions.INPUT.get(cli).trim());
Assert.assertEquals(log4jProperty, LoadOptions.LOG4J_PROPERTIES.get(cli).trim());
Assert.assertEquals("2", LoadOptions.NUM_THREADS.get(cli).trim());
Assert.assertEquals("128", LoadOptions.BATCH_SIZE.get(cli).trim());
}
use of org.apache.commons.cli.PosixParser in project metron by apache.
the class GeoEnrichmentLoaderTest method testCommandLineShortOpts.
@Test
public void testCommandLineShortOpts() throws Exception {
String[] argv = { "-g testGeoUrl", "-r /test/remoteDir", "-t /test/tmpDir", "-z test:2181" };
String[] otherArgs = new GenericOptionsParser(argv).getRemainingArgs();
CommandLine cli = GeoEnrichmentLoader.GeoEnrichmentOptions.parse(new PosixParser(), otherArgs);
Assert.assertEquals("testGeoUrl", GeoEnrichmentLoader.GeoEnrichmentOptions.GEO_URL.get(cli).trim());
Assert.assertEquals("/test/remoteDir", GeoEnrichmentLoader.GeoEnrichmentOptions.REMOTE_DIR.get(cli).trim());
Assert.assertEquals("/test/tmpDir", GeoEnrichmentLoader.GeoEnrichmentOptions.TMP_DIR.get(cli).trim());
Assert.assertEquals("test:2181", GeoEnrichmentLoader.GeoEnrichmentOptions.ZK_QUORUM.get(cli).trim());
}
Aggregations