use of org.graylog2.plugin.Plugin in project graylog2-server by Graylog2.
the class PermissionsTest method testPluginPermissions.
@Test
public void testPluginPermissions() throws Exception {
final ImmutableSet<Permission> pluginPermissions = ImmutableSet.of(Permission.create("foo:bar", "bar"), Permission.create("foo:baz", "baz"), Permission.create("hello:world", "hello"));
final PermissionsPluginPermissions plugin = new PermissionsPluginPermissions(pluginPermissions);
final Permissions permissions = new Permissions(ImmutableSet.of(restPermissions, plugin));
assertThat(permissions.allPermissionsMap().get("foo")).containsOnly("bar", "baz");
assertThat(permissions.allPermissionsMap().get("hello")).containsOnly("world");
}
use of org.graylog2.plugin.Plugin in project graylog2-server by Graylog2.
the class CmdLineTool method installPluginConfigAndBindings.
private PluginBindings installPluginConfigAndBindings(String pluginPath, ChainingClassLoader classLoader) {
final Set<Plugin> plugins = loadPlugins(pluginPath, classLoader);
final PluginBindings pluginBindings = new PluginBindings(plugins);
for (final Plugin plugin : plugins) {
for (final PluginModule pluginModule : plugin.modules()) {
for (final PluginConfigBean configBean : pluginModule.getConfigBeans()) {
jadConfig.addConfigurationBean(configBean);
}
}
}
return pluginBindings;
}
use of org.graylog2.plugin.Plugin 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;
}
use of org.graylog2.plugin.Plugin in project graylog2-server by Graylog2.
the class CmdLineTool method run.
@Override
public void run() {
final Level logLevel = setupLogger();
if (isDumpDefaultConfig()) {
dumpDefaultConfigAndExit();
}
// This is holding all our metrics.
MetricRegistry metricRegistry = MetricRegistryFactory.create();
featureFlags = getFeatureFlags(metricRegistry);
installConfigRepositories();
installCommandConfig();
beforeStart();
beforeStart(parseAndGetTLSConfiguration(), parseAndGetPathConfiguration(configFile));
processConfiguration(jadConfig);
coreConfigInjector = setupCoreConfigInjector();
final Set<Plugin> plugins = loadPlugins(getPluginPath(configFile), chainingClassLoader);
installPluginConfig(plugins);
processConfiguration(jadConfig);
if (isDumpConfig()) {
dumpCurrentConfigAndExit();
}
if (!validateConfiguration()) {
LOG.error("Validating configuration file failed - exiting.");
System.exit(1);
}
final List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
LOG.info("Running with JVM arguments: {}", Joiner.on(' ').join(arguments));
beforeInjectorCreation(plugins);
injector = setupInjector(new NamedConfigParametersModule(jadConfig.getConfigurationBeans()), new PluginBindings(plugins), binder -> binder.bind(MetricRegistry.class).toInstance(metricRegistry));
if (injector == null) {
LOG.error("Injector could not be created, exiting! (Please include the previous error messages in bug " + "reports.)");
System.exit(1);
}
addInstrumentedAppender(metricRegistry, logLevel);
// Report metrics via JMX.
final JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).build();
reporter.start();
startCommand();
}
use of org.graylog2.plugin.Plugin 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;
}
}
Aggregations