Search in sources :

Example 6 with ProfilerConfig

use of org.apache.metron.common.configuration.profiler.ProfilerConfig in project metron by apache.

the class ZKConfigurationsCacheIntegrationTest method validateBaseWrite.

@Test
public void validateBaseWrite() throws Exception {
    File globalConfigFile = new File(TestConstants.SAMPLE_CONFIG_PATH + "/global.json");
    Map<String, Object> expectedGlobalConfig = JSONUtils.INSTANCE.load(globalConfigFile, JSONUtils.MAP_SUPPLIER);
    // indexing
    {
        File inFile = new File(TestConstants.SAMPLE_CONFIG_PATH + "/indexing/test.json");
        Map<String, Object> expectedConfig = JSONUtils.INSTANCE.load(inFile, JSONUtils.MAP_SUPPLIER);
        IndexingConfigurations config = cache.get(IndexingConfigurations.class);
        assertEventually(() -> Assert.assertEquals(expectedConfig, config.getSensorIndexingConfig("test")));
        assertEventually(() -> Assert.assertEquals(expectedGlobalConfig, config.getGlobalConfig()));
        assertEventually(() -> Assert.assertNull(config.getSensorIndexingConfig("notthere", false)));
    }
    // enrichment
    {
        File inFile = new File(TestConstants.SAMPLE_CONFIG_PATH + "/enrichments/test.json");
        SensorEnrichmentConfig expectedConfig = JSONUtils.INSTANCE.load(inFile, SensorEnrichmentConfig.class);
        EnrichmentConfigurations config = cache.get(EnrichmentConfigurations.class);
        assertEventually(() -> Assert.assertEquals(expectedConfig, config.getSensorEnrichmentConfig("test")));
        assertEventually(() -> Assert.assertEquals(expectedGlobalConfig, config.getGlobalConfig()));
        assertEventually(() -> Assert.assertNull(config.getSensorEnrichmentConfig("notthere")));
    }
    // parsers
    {
        File inFile = new File(TestConstants.PARSER_CONFIGS_PATH + "/parsers/bro.json");
        SensorParserConfig expectedConfig = JSONUtils.INSTANCE.load(inFile, SensorParserConfig.class);
        ParserConfigurations config = cache.get(ParserConfigurations.class);
        assertEventually(() -> Assert.assertEquals(expectedConfig, config.getSensorParserConfig("bro")));
        assertEventually(() -> Assert.assertEquals(expectedGlobalConfig, config.getGlobalConfig()));
        assertEventually(() -> Assert.assertNull(config.getSensorParserConfig("notthere")));
    }
    // profiler
    {
        File inFile = new File(profilerDir, "/readme-example-1/profiler.json");
        ProfilerConfig expectedConfig = JSONUtils.INSTANCE.load(inFile, ProfilerConfig.class);
        ProfilerConfigurations config = cache.get(ProfilerConfigurations.class);
        assertEventually(() -> Assert.assertEquals(expectedConfig, config.getProfilerConfig()));
        assertEventually(() -> Assert.assertEquals(expectedGlobalConfig, config.getGlobalConfig()));
    }
}
Also used : ProfilerConfig(org.apache.metron.common.configuration.profiler.ProfilerConfig) File(java.io.File) Map(java.util.Map) SensorEnrichmentConfig(org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig) ProfilerConfigurations(org.apache.metron.common.configuration.profiler.ProfilerConfigurations)

Example 7 with ProfilerConfig

use of org.apache.metron.common.configuration.profiler.ProfilerConfig in project metron by apache.

the class StandAloneProfilerTest method createProfiler.

/**
 * Creates the StandAloneProfiler
 *
 * @param profileJson The Profiler configuration to use as a String containing JSON.
 * @throws Exception
 */
private StandAloneProfiler createProfiler(String profileJson) throws Exception {
    // the TTL and max routes need not be bounded
    long profileTimeToLiveMillis = Long.MAX_VALUE;
    long maxNumberOfRoutes = Long.MAX_VALUE;
    ProfilerConfig config = toProfilerConfig(profileJson);
    return new StandAloneProfiler(config, periodDurationMillis, profileTimeToLiveMillis, maxNumberOfRoutes, context);
}
Also used : ProfilerConfig(org.apache.metron.common.configuration.profiler.ProfilerConfig)

Example 8 with ProfilerConfig

use of org.apache.metron.common.configuration.profiler.ProfilerConfig in project metron by apache.

the class DefaultClockFactoryTest method testCreateEventTimeClock.

/**
 * When a 'timestampField' is defined the factory should return a clock
 * that deals with event time.
 */
@Test
public void testCreateEventTimeClock() {
    // configure the profiler to use event time
    ProfilerConfig config = new ProfilerConfig();
    config.setTimestampField(Optional.of("timestamp"));
    // the factory should return a clock that handles 'event time'
    Clock clock = clockFactory.createClock(config);
    assertTrue(clock instanceof EventTimeClock);
}
Also used : ProfilerConfig(org.apache.metron.common.configuration.profiler.ProfilerConfig) Test(org.junit.Test)

Example 9 with ProfilerConfig

use of org.apache.metron.common.configuration.profiler.ProfilerConfig in project metron by apache.

the class ProfileSplitterBoltTest method testOnlyIfMissing.

/**
 * All messages are applied to a profile where 'onlyif' is missing.  A profile with no
 * 'onlyif' is treated the same as if 'onlyif=true'.
 */
@Test
public void testOnlyIfMissing() throws Exception {
    ProfilerConfig config = toProfilerConfig(profileWithOnlyIfMissing);
    ProfileSplitterBolt bolt = createBolt(config);
    bolt.execute(tuple);
    // a tuple should be emitted for the downstream profile builder
    verify(outputCollector, times(1)).emit(eq(tuple), any(Values.class));
    // the original tuple should be ack'd
    verify(outputCollector, times(1)).ack(eq(tuple));
}
Also used : ProfilerConfig(org.apache.metron.common.configuration.profiler.ProfilerConfig) Values(org.apache.storm.tuple.Values) Test(org.junit.Test) BaseBoltTest(org.apache.metron.test.bolt.BaseBoltTest)

Example 10 with ProfilerConfig

use of org.apache.metron.common.configuration.profiler.ProfilerConfig in project metron by apache.

the class ProfileSplitterBoltTest method testNoProfilesDefined.

/**
 * No tuples should be emitted, if no profiles are defined.
 */
@Test
public void testNoProfilesDefined() throws Exception {
    // setup the bolt and execute a tuple
    ProfilerConfig config = toProfilerConfig(noProfilesDefined);
    ProfileSplitterBolt bolt = createBolt(config);
    bolt.execute(tuple);
    // no tuple should be emitted
    verify(outputCollector, times(0)).emit(any(Tuple.class), any());
    // the original tuple should be ack'd
    verify(outputCollector, times(1)).ack(eq(tuple));
}
Also used : ProfilerConfig(org.apache.metron.common.configuration.profiler.ProfilerConfig) Tuple(org.apache.storm.tuple.Tuple) Test(org.junit.Test) BaseBoltTest(org.apache.metron.test.bolt.BaseBoltTest)

Aggregations

ProfilerConfig (org.apache.metron.common.configuration.profiler.ProfilerConfig)13 Test (org.junit.Test)10 BaseBoltTest (org.apache.metron.test.bolt.BaseBoltTest)8 Values (org.apache.storm.tuple.Values)6 ProfileConfig (org.apache.metron.common.configuration.profiler.ProfileConfig)3 File (java.io.File)1 Map (java.util.Map)1 SensorEnrichmentConfig (org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig)1 ProfilerConfigurations (org.apache.metron.common.configuration.profiler.ProfilerConfigurations)1 Clock (org.apache.metron.profiler.clock.Clock)1 Tuple (org.apache.storm.tuple.Tuple)1 JSONObject (org.json.simple.JSONObject)1