Search in sources :

Example 96 with PosixParser

use of org.apache.commons.cli.PosixParser in project metron by apache.

the class LoadOptionsTest method testThreadsByCores.

@Test
public void testThreadsByCores() throws Exception {
    CommandLine cli = LoadOptions.parse(new PosixParser(), new String[] { "-p", "2C" });
    EnumMap<LoadOptions, Optional<Object>> results = LoadOptions.createConfig(cli);
    Assert.assertEquals(2 * Runtime.getRuntime().availableProcessors(), results.get(LoadOptions.NUM_THREADS).get());
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) Optional(java.util.Optional) PosixParser(org.apache.commons.cli.PosixParser) Test(org.junit.Test)

Example 97 with PosixParser

use of org.apache.commons.cli.PosixParser in project metron by apache.

the class LoadOptionsTest method testThreadsByNum.

@Test
public void testThreadsByNum() throws Exception {
    CommandLine cli = LoadOptions.parse(new PosixParser(), new String[] { "-p", "5" });
    EnumMap<LoadOptions, Optional<Object>> results = LoadOptions.createConfig(cli);
    Assert.assertEquals(5, results.get(LoadOptions.NUM_THREADS).get());
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) Optional(java.util.Optional) PosixParser(org.apache.commons.cli.PosixParser) Test(org.junit.Test)

Example 98 with PosixParser

use of org.apache.commons.cli.PosixParser in project metron by apache.

the class LoadOptionsTest method testHappyPath.

@Test
public void testHappyPath() throws Exception {
    CommandLine cli = LoadOptions.parse(new PosixParser(), new String[] { "-eps", "1000", "-ot", "foo" });
    EnumMap<LoadOptions, Optional<Object>> results = LoadOptions.createConfig(cli);
    Assert.assertEquals(1000L, results.get(LoadOptions.EPS).get());
    Assert.assertEquals("foo", results.get(LoadOptions.OUTPUT_TOPIC).get());
    Assert.assertEquals(LoadGenerator.CONSUMER_GROUP, results.get(LoadOptions.CONSUMER_GROUP).get());
    Assert.assertEquals(Runtime.getRuntime().availableProcessors(), results.get(LoadOptions.NUM_THREADS).get());
    Assert.assertFalse(results.get(LoadOptions.BIASED_SAMPLE).isPresent());
    Assert.assertFalse(results.get(LoadOptions.CSV).isPresent());
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) Optional(java.util.Optional) PosixParser(org.apache.commons.cli.PosixParser) Test(org.junit.Test)

Example 99 with PosixParser

use of org.apache.commons.cli.PosixParser in project metron by apache.

the class ConfigurationManager method main.

public static void main(String... argv) throws Exception {
    CommandLineParser parser = new PosixParser();
    CommandLine cli = ConfigurationOptions.parse(parser, argv);
    ConfigurationManager manager = new ConfigurationManager();
    manager.run(cli);
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) PosixParser(org.apache.commons.cli.PosixParser) CommandLineParser(org.apache.commons.cli.CommandLineParser)

Example 100 with PosixParser

use of org.apache.commons.cli.PosixParser in project metron by apache.

the class ConfigurationFunctionsTest method pushConfigs.

private static void pushConfigs(String inputPath) throws Exception {
    String[] args = new String[] { "-z", zookeeperUrl, "--mode", "PUSH", "--input_dir", inputPath };
    ConfigurationManager manager = new ConfigurationManager();
    manager.run(ConfigurationManager.ConfigurationOptions.parse(new PosixParser(), args));
}
Also used : PosixParser(org.apache.commons.cli.PosixParser) ConfigurationManager(org.apache.metron.common.cli.ConfigurationManager)

Aggregations

PosixParser (org.apache.commons.cli.PosixParser)103 CommandLine (org.apache.commons.cli.CommandLine)97 CommandLineParser (org.apache.commons.cli.CommandLineParser)67 Options (org.apache.commons.cli.Options)56 ParseException (org.apache.commons.cli.ParseException)51 File (java.io.File)24 IOException (java.io.IOException)20 HelpFormatter (org.apache.commons.cli.HelpFormatter)16 Optional (java.util.Optional)10 Test (org.junit.Test)9 List (java.util.List)8 Configuration (org.apache.hadoop.conf.Configuration)8 GenericOptionsParser (org.apache.hadoop.util.GenericOptionsParser)7 SystemExitException (org.apache.openejb.cli.SystemExitException)7 Option (org.apache.commons.cli.Option)6 Parser (org.apache.commons.cli.Parser)6 Properties (java.util.Properties)5 Path (org.apache.hadoop.fs.Path)5 ArrayList (java.util.ArrayList)4 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)4