Search in sources :

Example 1 with PerformanceLogger

use of org.apache.metron.common.performance.PerformanceLogger in project metron by apache.

the class GenericEnrichmentBolt method prepare.

@Override
public void prepare(Map conf, TopologyContext topologyContext, OutputCollector collector) {
    super.prepare(conf, topologyContext, collector);
    this.collector = collector;
    if (this.maxCacheSize == null)
        throw new IllegalStateException("MAX_CACHE_SIZE_OBJECTS_NUM must be specified");
    if (this.maxTimeRetain == null)
        throw new IllegalStateException("MAX_TIME_RETAIN_MINUTES must be specified");
    if (this.adapter == null)
        throw new IllegalStateException("Adapter must be specified");
    loader = key -> adapter.enrich(key);
    cache = Caffeine.newBuilder().maximumSize(maxCacheSize).expireAfterWrite(maxTimeRetain, TimeUnit.MINUTES).build(loader);
    boolean success = adapter.initializeAdapter(getConfigurations().getGlobalConfig());
    if (!success) {
        LOG.error("[Metron] GenericEnrichmentBolt could not initialize adapter");
        throw new IllegalStateException("Could not initialize adapter...");
    }
    perfLog = new PerformanceLogger(() -> getConfigurations().getGlobalConfig(), GenericEnrichmentBolt.Perf.class.getName());
    initializeStellar();
}
Also used : PerformanceLogger(org.apache.metron.common.performance.PerformanceLogger)

Example 2 with PerformanceLogger

use of org.apache.metron.common.performance.PerformanceLogger in project metron by apache.

the class SplitBolt method prepare.

@Override
public final void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) {
    super.prepare(map, topologyContext, outputCollector);
    perfLog = new PerformanceLogger(() -> getConfigurations().getGlobalConfig(), Perf.class.getName());
    collector = outputCollector;
    prepare(map, topologyContext);
}
Also used : PerformanceLogger(org.apache.metron.common.performance.PerformanceLogger)

Example 3 with PerformanceLogger

use of org.apache.metron.common.performance.PerformanceLogger in project metron by apache.

the class JoinBolt method prepare.

@Override
public void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) {
    super.prepare(map, topologyContext, outputCollector);
    perfLog = new PerformanceLogger(() -> getConfigurations().getGlobalConfig(), Perf.class.getName());
    keyGetStrategy = MessageGetters.OBJECT_FROM_FIELD.get("key");
    subgroupGetStrategy = MessageGetters.OBJECT_FROM_FIELD.get("subgroup");
    messageGetStrategy = MessageGetters.OBJECT_FROM_FIELD.get("message");
    this.collector = outputCollector;
    if (this.maxCacheSize == null) {
        throw new IllegalStateException("maxCacheSize must be specified");
    }
    if (this.maxTimeRetain == null) {
        throw new IllegalStateException("maxTimeRetain must be specified");
    }
    loader = s -> new HashMap<>();
    cache = Caffeine.newBuilder().maximumSize(maxCacheSize).expireAfterWrite(maxTimeRetain, TimeUnit.MINUTES).removalListener(new JoinRemoveListener()).build(loader);
    prepare(map, topologyContext);
}
Also used : PerformanceLogger(org.apache.metron.common.performance.PerformanceLogger)

Example 4 with PerformanceLogger

use of org.apache.metron.common.performance.PerformanceLogger in project metron by apache.

the class UnifiedEnrichmentBolt method prepare.

@Override
public final void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) {
    super.prepare(map, topologyContext, outputCollector);
    collector = outputCollector;
    if (this.maxCacheSize == null) {
        throw new IllegalStateException("MAX_CACHE_SIZE_OBJECTS_NUM must be specified");
    }
    if (this.maxTimeRetain == null) {
        throw new IllegalStateException("MAX_TIME_RETAIN_MINUTES must be specified");
    }
    if (this.enrichmentsByType.isEmpty()) {
        throw new IllegalStateException("Adapter must be specified");
    }
    for (Map.Entry<String, EnrichmentAdapter<CacheKey>> adapterKv : enrichmentsByType.entrySet()) {
        boolean success = adapterKv.getValue().initializeAdapter(getConfigurations().getGlobalConfig());
        if (!success) {
            LOG.error("[Metron] Could not initialize adapter: " + adapterKv.getKey());
            throw new IllegalStateException("Could not initialize adapter: " + adapterKv.getKey());
        }
    }
    WorkerPoolStrategies workerPoolStrategy = WorkerPoolStrategies.FIXED;
    if (map.containsKey(THREADPOOL_TYPE_TOPOLOGY_CONF)) {
        workerPoolStrategy = WorkerPoolStrategies.valueOf(map.get(THREADPOOL_TYPE_TOPOLOGY_CONF) + "");
    }
    if (map.containsKey(THREADPOOL_NUM_THREADS_TOPOLOGY_CONF)) {
        int numThreads = getNumThreads(map.get(THREADPOOL_NUM_THREADS_TOPOLOGY_CONF));
        ConcurrencyContext.get(strategy).initialize(numThreads, maxCacheSize, maxTimeRetain, workerPoolStrategy, LOG, captureCacheStats);
    } else {
        throw new IllegalStateException("You must pass " + THREADPOOL_NUM_THREADS_TOPOLOGY_CONF + " via storm config.");
    }
    messageGetter = this.getterStrategy.get(messageFieldName);
    enricher = new ParallelEnricher(enrichmentsByType, ConcurrencyContext.get(strategy), captureCacheStats);
    perfLog = new PerformanceLogger(() -> getConfigurations().getGlobalConfig(), Perf.class.getName());
    GeoLiteDatabase.INSTANCE.update((String) getConfigurations().getGlobalConfig().get(GeoLiteDatabase.GEO_HDFS_FILE));
    initializeStellar();
    enrichmentContext = new EnrichmentContext(StellarFunctions.FUNCTION_RESOLVER(), stellarContext);
}
Also used : PerformanceLogger(org.apache.metron.common.performance.PerformanceLogger) EnrichmentAdapter(org.apache.metron.enrichment.interfaces.EnrichmentAdapter) WorkerPoolStrategies(org.apache.metron.enrichment.parallel.WorkerPoolStrategies) HashMap(java.util.HashMap) Map(java.util.Map) ParallelEnricher(org.apache.metron.enrichment.parallel.ParallelEnricher) EnrichmentContext(org.apache.metron.enrichment.parallel.EnrichmentContext)

Aggregations

PerformanceLogger (org.apache.metron.common.performance.PerformanceLogger)4 HashMap (java.util.HashMap)1 Map (java.util.Map)1 EnrichmentAdapter (org.apache.metron.enrichment.interfaces.EnrichmentAdapter)1 EnrichmentContext (org.apache.metron.enrichment.parallel.EnrichmentContext)1 ParallelEnricher (org.apache.metron.enrichment.parallel.ParallelEnricher)1 WorkerPoolStrategies (org.apache.metron.enrichment.parallel.WorkerPoolStrategies)1