use of org.apache.metron.enrichment.parallel.ParallelEnricher 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);
}
Aggregations