Search in sources :

Example 11 with PluginMetaData

use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.

the class CmdLineTool method loadPlugins.

protected Set<Plugin> loadPlugins(Path pluginPath, ChainingClassLoader chainingClassLoader) {
    final Set<Plugin> plugins = new HashSet<>();
    final PluginLoader pluginLoader = new PluginLoader(pluginPath.toFile(), chainingClassLoader, coreConfigInjector);
    for (Plugin plugin : pluginLoader.loadPlugins()) {
        final PluginMetaData metadata = plugin.metadata();
        if (capabilities().containsAll(metadata.getRequiredCapabilities())) {
            if (version.sameOrHigher(metadata.getRequiredVersion())) {
                LOG.info("Loaded plugin: {}", plugin);
                plugins.add(plugin);
            } else {
                LOG.error("Plugin \"" + metadata.getName() + "\" requires version " + metadata.getRequiredVersion() + " - not loading!");
            }
        } else {
            LOG.debug("Skipping plugin \"{}\" because some capabilities are missing ({}).", metadata.getName(), Sets.difference(plugin.metadata().getRequiredCapabilities(), capabilities()));
        }
    }
    return plugins;
}
Also used : PluginMetaData(org.graylog2.plugin.PluginMetaData) PluginLoader(org.graylog2.shared.plugins.PluginLoader) Plugin(org.graylog2.plugin.Plugin) HashSet(java.util.HashSet)

Example 12 with PluginMetaData

use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.

the class EventDefinitionFacadeTest method setUp.

@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
    objectMapper.registerSubtypes(AggregationEventProcessorConfig.class, PersistToStreamsStorageHandler.Config.class, TemplateFieldValueProvider.Config.class, AggregationEventProcessorConfigEntity.class);
    stateService = mock(DBEventProcessorStateService.class);
    jobDefinitionService = mock(DBJobDefinitionService.class);
    jobTriggerService = mock(DBJobTriggerService.class);
    jobSchedulerClock = mock(JobSchedulerClock.class);
    eventDefinitionService = new DBEventDefinitionService(mongodb.mongoConnection(), mapperProvider, stateService, entityOwnershipService);
    eventDefinitionHandler = new EventDefinitionHandler(eventDefinitionService, jobDefinitionService, jobTriggerService, jobSchedulerClock);
    Set<PluginMetaData> pluginMetaData = new HashSet<>();
    facade = new EventDefinitionFacade(objectMapper, eventDefinitionHandler, pluginMetaData, jobDefinitionService, eventDefinitionService, userService);
}
Also used : PersistToStreamsStorageHandler(org.graylog.events.processor.storage.PersistToStreamsStorageHandler) TemplateFieldValueProvider(org.graylog.events.fields.providers.TemplateFieldValueProvider) DBJobTriggerService(org.graylog.scheduler.DBJobTriggerService) JobSchedulerClock(org.graylog.scheduler.clock.JobSchedulerClock) PluginMetaData(org.graylog2.plugin.PluginMetaData) DBJobDefinitionService(org.graylog.scheduler.DBJobDefinitionService) DBEventDefinitionService(org.graylog.events.processor.DBEventDefinitionService) EventDefinitionHandler(org.graylog.events.processor.EventDefinitionHandler) DBEventProcessorStateService(org.graylog.events.processor.DBEventProcessorStateService) HashSet(java.util.HashSet) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Aggregations

Before (org.junit.Before)6 PluginMetaData (org.graylog2.plugin.PluginMetaData)5 HashSet (java.util.HashSet)4 SuppressForbidden (org.graylog2.shared.SuppressForbidden)4 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)3 ClusterEventBus (org.graylog2.events.ClusterEventBus)3 Plugin (org.graylog2.plugin.Plugin)3 HashMap (java.util.HashMap)2 Constraint (org.graylog2.contentpacks.model.constraints.Constraint)2 GraylogVersionConstraint (org.graylog2.contentpacks.model.constraints.GraylogVersionConstraint)2 PluginVersionConstraint (org.graylog2.contentpacks.model.constraints.PluginVersionConstraint)2 Test (org.junit.Test)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 EventBus (com.google.common.eventbus.EventBus)1 TypeLiteral (com.google.inject.TypeLiteral)1 Requirement (com.vdurmont.semver4j.Requirement)1 File (java.io.File)1 TemplateFieldValueProvider (org.graylog.events.fields.providers.TemplateFieldValueProvider)1 DBEventDefinitionService (org.graylog.events.processor.DBEventDefinitionService)1