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()));
}
}
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);
}
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);
}
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));
}
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));
}
Aggregations