use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.
the class CmdLineTool method loadPlugins.
protected Set<Plugin> loadPlugins(String pluginPath, ChainingClassLoader chainingClassLoader) {
final File pluginDir = new File(pluginPath);
final Set<Plugin> plugins = new HashSet<>();
final PluginLoader pluginLoader = new PluginLoader(pluginDir, chainingClassLoader);
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;
}
use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.
the class PluginBindings method configure.
@Override
protected void configure() {
final Multibinder<Plugin> pluginbinder = Multibinder.newSetBinder(binder(), Plugin.class);
final Multibinder<PluginMetaData> pluginMetaDataBinder = Multibinder.newSetBinder(binder(), PluginMetaData.class);
// Make sure there is a binding for the plugin rest resource classes to avoid binding errors when running
// without plugins.
MapBinder.newMapBinder(binder(), new TypeLiteral<String>() {
}, new TypeLiteral<Class<? extends PluginRestResource>>() {
}).permitDuplicates();
// Make sure there is a binding for the PluginUISettingsProvider classes to avoid binding errors when running
// without plugins
MapBinder.newMapBinder(binder(), String.class, PluginUISettingsProvider.class).permitDuplicates();
for (final Plugin plugin : plugins) {
pluginbinder.addBinding().toInstance(plugin);
for (final PluginModule pluginModule : plugin.modules()) {
binder().install(pluginModule);
}
pluginMetaDataBinder.addBinding().toInstance(plugin.metadata());
}
}
use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.
the class PluginVersionConstraint method of.
public static PluginVersionConstraint of(PluginMetaData pluginMetaData) {
final Version version = pluginMetaData.getVersion();
final String versionString = version.toString().replace("-SNAPSHOT", "");
final Requirement requirement = Requirement.buildNPM(">=" + versionString);
return builder().pluginId(pluginMetaData.getUniqueId()).version(requirement).build();
}
use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.
the class LookupCacheFacadeTest method setUp.
@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
final ClusterEventBus clusterEventBus = new ClusterEventBus("cluster-event-bus", Executors.newSingleThreadExecutor());
cacheService = new DBCacheService(mongodb.mongoConnection(), new MongoJackObjectMapperProvider(objectMapper), clusterEventBus);
pluginMetaData = new HashSet<>();
facade = new LookupCacheFacade(objectMapper, cacheService, pluginMetaData);
}
use of org.graylog2.plugin.PluginMetaData in project graylog2-server by Graylog2.
the class InputFacadeTest method setUp.
@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
final MetricRegistry metricRegistry = new MetricRegistry();
final ClusterEventBus clusterEventBus = new ClusterEventBus("cluster-event-bus", Executors.newSingleThreadExecutor());
final GrokPatternService grokPatternService = new InMemoryGrokPatternService(clusterEventBus);
grokPatternService.save(GrokPattern.create("GREEDY", ".*"));
final EventBus clusterBus = new EventBus();
final GrokPatternRegistry grokPatternRegistry = new GrokPatternRegistry(clusterBus, grokPatternService, Executors.newScheduledThreadPool(1));
final ExtractorFactory extractorFactory = new ExtractorFactory(metricRegistry, grokPatternRegistry, lookupTableService);
final ConverterFactory converterFactory = new ConverterFactory(lookupTableService);
inputService = new InputServiceImpl(mongodb.mongoConnection(), extractorFactory, converterFactory, messageInputFactory, clusterEventBus);
final InputRegistry inputRegistry = new InputRegistry();
Set<PluginMetaData> pluginMetaData = new HashSet<>();
Map<String, MessageInput.Factory<? extends MessageInput>> inputFactories = new HashMap<>();
final FakeHttpMessageInput.Factory fakeHttpMessageInputFactory = mock(FakeHttpMessageInput.Factory.class);
final FakeHttpMessageInput.Descriptor fakeHttpMessageInputDescriptor = mock(FakeHttpMessageInput.Descriptor.class);
when(fakeHttpMessageInputFactory.getDescriptor()).thenReturn(fakeHttpMessageInputDescriptor);
final RawUDPInput.Factory rawUDPInputFactory = mock(RawUDPInput.Factory.class);
final RawUDPInput.Descriptor rawUDPInputDescriptor = mock(RawUDPInput.Descriptor.class);
when(rawUDPInputFactory.getDescriptor()).thenReturn(rawUDPInputDescriptor);
inputFactories.put("org.graylog2.inputs.random.FakeHttpMessageInput", fakeHttpMessageInputFactory);
inputFactories.put("org.graylog2.inputs.raw.udp.RawUDPInput", rawUDPInputFactory);
facade = new InputFacade(objectMapper, inputService, inputRegistry, dbLookupTableService, grokPatternService, messageInputFactory, extractorFactory, converterFactory, serverStatus, pluginMetaData, inputFactories);
}
Aggregations