Search in sources :

Example 1 with LoggingServiceListener

use of org.graylog2.utilities.LoggingServiceListener in project graylog2-server by Graylog2.

the class LookupTableService method createCache.

private LookupCache createCache(CacheDto dto) {
    try {
        final LookupCache.Factory<? extends LookupCache> factory = cacheFactories.get(dto.config().type());
        if (factory == null) {
            LOG.warn("Unable to load cache {} of type {}, missing a factory. Is a required plugin missing?", dto.name(), dto.config().type());
            // TODO system notification
            return null;
        }
        final LookupCache cache = factory.create(dto.id(), dto.name(), dto.config());
        cache.addListener(new LoggingServiceListener("Cache", String.format(Locale.ENGLISH, "%s/%s [@%s]", dto.name(), dto.id(), objectId(cache)), LOG), scheduler);
        return cache;
    } catch (Exception e) {
        LOG.error("Couldn't create cache <{}/{}>", dto.name(), dto.id(), e);
        return null;
    }
}
Also used : LookupCache(org.graylog2.plugin.lookup.LookupCache) LoggingServiceListener(org.graylog2.utilities.LoggingServiceListener)

Example 2 with LoggingServiceListener

use of org.graylog2.utilities.LoggingServiceListener in project graylog2-server by Graylog2.

the class LookupTableService method addListeners.

protected void addListeners(LookupDataAdapter adapter, DataAdapterDto dto) {
    adapter.addListener(new LoggingServiceListener("Data Adapter", String.format(Locale.ENGLISH, "%s/%s [@%s]", dto.name(), dto.id(), objectId(adapter)), LOG), scheduler);
    // Each adapter needs to be added to the refresh scheduler
    adapter.addListener(adapterRefreshService.newServiceListener(adapter), scheduler);
}
Also used : LoggingServiceListener(org.graylog2.utilities.LoggingServiceListener)

Aggregations

LoggingServiceListener (org.graylog2.utilities.LoggingServiceListener)2 LookupCache (org.graylog2.plugin.lookup.LookupCache)1