Search in sources :

Example 61 with SensorParserConfig

use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.

the class ParserTopologyCLITest method testParserParallelism.

@Test
public void testParserParallelism() throws Exception {
    testConfigOption(ParserTopologyCLI.ParserOptions.PARSER_PARALLELISM, "10", input -> input.getParserParallelism().equals(10), () -> {
        SensorParserConfig config = getBaseConfig();
        config.setParserParallelism(20);
        return Collections.singletonList(config);
    }, input -> input.getParserParallelism().equals(20));
}
Also used : SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) Test(org.junit.jupiter.api.Test)

Example 62 with SensorParserConfig

use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.

the class ParserTopologyCLITest method testTopologyConfig.

@Test
public void testTopologyConfig() throws Exception {
    File extraConfig = File.createTempFile("topologyConfig", "json");
    extraConfig.deleteOnExit();
    writeMap(extraConfig, new HashMap<String, Object>() {

        {
            put(Config.TOPOLOGY_DEBUG, true);
        }
    });
    testConfigOption(new EnumMap<ParserTopologyCLI.ParserOptions, String>(ParserTopologyCLI.ParserOptions.class) {

        {
            put(ParserTopologyCLI.ParserOptions.NUM_WORKERS, "10");
            put(ParserTopologyCLI.ParserOptions.NUM_ACKERS, "20");
            put(ParserTopologyCLI.ParserOptions.EXTRA_OPTIONS, extraConfig.getAbsolutePath());
        }
    }, input -> {
        Config c = input.getStormConf();
        return (int) c.get(Config.TOPOLOGY_WORKERS) == 10 && (int) c.get(Config.TOPOLOGY_ACKER_EXECUTORS) == 20 && (boolean) c.get(Config.TOPOLOGY_DEBUG);
    }, () -> {
        SensorParserConfig config = getBaseConfig();
        config.setStormConfig(new HashMap<String, Object>() {

            {
                put(Config.TOPOLOGY_WORKERS, 100);
                put(Config.TOPOLOGY_ACKER_EXECUTORS, 200);
            }
        });
        return Collections.singletonList(config);
    }, input -> {
        Config c = input.getStormConf();
        return (int) c.get(Config.TOPOLOGY_WORKERS) == 100 && (int) c.get(Config.TOPOLOGY_ACKER_EXECUTORS) == 200 && !c.containsKey(Config.TOPOLOGY_DEBUG);
    });
}
Also used : SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) Config(org.apache.storm.Config) SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 63 with SensorParserConfig

use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.

the class ParserTopologyCLITest method testParserNumTasksMultiple.

@Test
public void testParserNumTasksMultiple() throws Exception {
    testConfigOption(ParserTopologyCLI.ParserOptions.PARSER_NUM_TASKS, "10", input -> input.getParserNumTasks().equals(10), () -> {
        SensorParserConfig config = getBaseConfig();
        config.setParserNumTasks(20);
        return Collections.singletonList(config);
    }, input -> input.getParserNumTasks().equals(20));
}
Also used : SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) Test(org.junit.jupiter.api.Test)

Example 64 with SensorParserConfig

use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.

the class ParserTopologyCLITest method testTopologyConfig_fromConfigExplicitly.

@Test
public void testTopologyConfig_fromConfigExplicitly() throws Exception {
    testConfigOption(new EnumMap<ParserTopologyCLI.ParserOptions, String>(ParserTopologyCLI.ParserOptions.class) {

        {
            put(ParserTopologyCLI.ParserOptions.NUM_WORKERS, "10");
            put(ParserTopologyCLI.ParserOptions.NUM_ACKERS, "20");
        }
    }, input -> {
        Config c = input.getStormConf();
        return (int) c.get(Config.TOPOLOGY_WORKERS) == 10 && (int) c.get(Config.TOPOLOGY_ACKER_EXECUTORS) == 20;
    }, () -> {
        SensorParserConfig config = getBaseConfig();
        config.setNumWorkers(100);
        config.setNumAckers(200);
        return Collections.singletonList(config);
    }, input -> {
        Config c = input.getStormConf();
        return (int) c.get(Config.TOPOLOGY_WORKERS) == 100 && (int) c.get(Config.TOPOLOGY_ACKER_EXECUTORS) == 200;
    });
}
Also used : SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) Config(org.apache.storm.Config) SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) Test(org.junit.jupiter.api.Test)

Example 65 with SensorParserConfig

use of org.apache.metron.common.configuration.SensorParserConfig in project metron by apache.

the class ParserTopologyCLITest method testSpoutNumTasksMultiple.

@Test
public void testSpoutNumTasksMultiple() throws Exception {
    // Return one per spout.
    List<Integer> numTasksCli = new ArrayList<>();
    numTasksCli.add(10);
    numTasksCli.add(12);
    List<Integer> numTasksConfig = new ArrayList<>();
    numTasksConfig.add(20);
    numTasksConfig.add(30);
    testConfigOption(ParserTopologyCLI.ParserOptions.SPOUT_NUM_TASKS, "10,12", input -> input.getSpoutNumTasks().equals(numTasksCli), () -> {
        SensorParserConfig config = getBaseConfig();
        config.setSpoutNumTasks(20);
        SensorParserConfig config2 = getBaseConfig();
        config2.setSpoutNumTasks(30);
        List<SensorParserConfig> configs = new ArrayList<>();
        configs.add(config);
        configs.add(config2);
        return configs;
    }, input -> input.getSpoutNumTasks().equals(numTasksConfig));
}
Also used : SensorParserConfig(org.apache.metron.common.configuration.SensorParserConfig) Test(org.junit.jupiter.api.Test)

Aggregations

SensorParserConfig (org.apache.metron.common.configuration.SensorParserConfig)97 Test (org.junit.jupiter.api.Test)74 JSONObject (org.json.simple.JSONObject)40 FieldTransformer (org.apache.metron.common.configuration.FieldTransformer)20 ParserConfigurations (org.apache.metron.common.configuration.ParserConfigurations)19 HashMap (java.util.HashMap)15 Config (org.apache.storm.Config)7 BaseBoltTest (org.apache.metron.test.bolt.BaseBoltTest)6 File (java.io.File)5 Map (java.util.Map)5 CuratorFramework (org.apache.curator.framework.CuratorFramework)5 WriterHandler (org.apache.metron.parsers.bolt.WriterHandler)5 IOException (java.io.IOException)4 SensorParserGroup (org.apache.metron.common.configuration.SensorParserGroup)4 MetronError (org.apache.metron.common.error.MetronError)4 ImmutableList (com.google.common.collect.ImmutableList)3 List (java.util.List)3 CommandLine (org.apache.commons.cli.CommandLine)3 ParseException (org.apache.commons.cli.ParseException)3 PosixParser (org.apache.commons.cli.PosixParser)3