Search in sources :

Example 61 with GenericOptionsParser

use of org.apache.hadoop.util.GenericOptionsParser in project metron by apache.

the class SimpleFlatFileSummarizerTest method testArgs.

@Test
public void testArgs() throws Exception {
    String[] argv = { "-e extractor.json", "-o out.ser", "-l log4j", "-i input.csv", "-p 2", "-b 128", "-q" };
    Configuration config = new Configuration();
    String[] otherArgs = new GenericOptionsParser(config, argv).getRemainingArgs();
    CommandLine cli = SummarizeOptions.parse(new PosixParser(), otherArgs);
    Assert.assertEquals("extractor.json", SummarizeOptions.EXTRACTOR_CONFIG.get(cli).trim());
    Assert.assertEquals("input.csv", SummarizeOptions.INPUT.get(cli).trim());
    Assert.assertEquals("log4j", SummarizeOptions.LOG4J_PROPERTIES.get(cli).trim());
    Assert.assertEquals("2", SummarizeOptions.NUM_THREADS.get(cli).trim());
    Assert.assertEquals("128", SummarizeOptions.BATCH_SIZE.get(cli).trim());
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) Configuration(org.apache.hadoop.conf.Configuration) PosixParser(org.apache.commons.cli.PosixParser) GenericOptionsParser(org.apache.hadoop.util.GenericOptionsParser) Test(org.junit.Test)

Example 62 with GenericOptionsParser

use of org.apache.hadoop.util.GenericOptionsParser in project metron by apache.

the class GeoEnrichmentLoaderTest method testLoadGeoIpDatabase.

@Test
public void testLoadGeoIpDatabase() throws Exception {
    File dbFile = new File(remoteDir.getAbsolutePath() + "/GeoEnrichmentLoaderTest.mmdb");
    dbFile.createNewFile();
    String[] argv = { "--geo_url", "file://" + dbFile.getAbsolutePath(), "--remote_dir", remoteDir.getAbsolutePath(), "--tmp_dir", tmpDir.getAbsolutePath(), "--zk_quorum", "test:2181" };
    String[] otherArgs = new GenericOptionsParser(argv).getRemainingArgs();
    CommandLine cli = GeoEnrichmentLoader.GeoEnrichmentOptions.parse(new PosixParser(), otherArgs);
    GeoEnrichmentLoader loader = new MockGeoEnrichmentLoader();
    loader.loadGeoIpDatabase(cli);
    Configuration config = new Configuration();
    FileSystem fs = FileSystem.get(config);
    assertTrue(fs.exists(new Path(remoteDir + "/" + dbFile.getName())));
}
Also used : Path(org.apache.hadoop.fs.Path) CommandLine(org.apache.commons.cli.CommandLine) Configuration(org.apache.hadoop.conf.Configuration) PosixParser(org.apache.commons.cli.PosixParser) FileSystem(org.apache.hadoop.fs.FileSystem) File(java.io.File) GenericOptionsParser(org.apache.hadoop.util.GenericOptionsParser)

Example 63 with GenericOptionsParser

use of org.apache.hadoop.util.GenericOptionsParser in project metron by apache.

the class GeoEnrichmentLoaderTest method testCommandLineLongOpts.

@Test
public void testCommandLineLongOpts() throws Exception {
    String[] argv = { "--geo_url", "testGeoUrl", "--remote_dir", "/test/remoteDir", "--tmp_dir", "/test/tmpDir", "--zk_quorum", "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());
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) PosixParser(org.apache.commons.cli.PosixParser) GenericOptionsParser(org.apache.hadoop.util.GenericOptionsParser)

Aggregations

GenericOptionsParser (org.apache.hadoop.util.GenericOptionsParser)63 Configuration (org.apache.hadoop.conf.Configuration)44 Job (org.apache.hadoop.mapreduce.Job)26 Path (org.apache.hadoop.fs.Path)22 CommandLine (org.apache.commons.cli.CommandLine)12 HCatSchema (org.apache.hive.hcatalog.data.schema.HCatSchema)10 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)8 PosixParser (org.apache.commons.cli.PosixParser)7 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)7 IOException (java.io.IOException)6 Options (org.apache.commons.cli.Options)6 FileSystem (org.apache.hadoop.fs.FileSystem)6 HashMap (java.util.HashMap)5 YarnUncaughtExceptionHandler (org.apache.hadoop.yarn.YarnUncaughtExceptionHandler)5 ArrayList (java.util.ArrayList)4 ParseException (org.apache.commons.cli.ParseException)4 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)4 JobConf (org.apache.hadoop.mapred.JobConf)4 File (java.io.File)3 Random (java.util.Random)3