Search in sources :

Example 6 with ChainingClassLoader

use of org.graylog2.shared.plugins.ChainingClassLoader in project graylog2-server by Graylog2.

the class V20170110150100_FixAlertConditionsMigrationTest method setUp.

@Before
public void setUp() throws Exception {
    this.clusterConfigService = spy(new ClusterConfigServiceImpl(objectMapperProvider, fongoRule.getConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), new ClusterEventBus()));
    final MongoConnection mongoConnection = spy(fongoRule.getConnection());
    final MongoDatabase mongoDatabase = spy(fongoRule.getDatabase());
    when(mongoConnection.getMongoDatabase()).thenReturn(mongoDatabase);
    this.collection = spy(mongoDatabase.getCollection("streams"));
    when(mongoDatabase.getCollection("streams")).thenReturn(collection);
    this.migration = new V20170110150100_FixAlertConditionsMigration(mongoConnection, clusterConfigService);
}
Also used : ClusterConfigServiceImpl(org.graylog2.cluster.ClusterConfigServiceImpl) MongoConnection(org.graylog2.database.MongoConnection) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) ClusterEventBus(org.graylog2.events.ClusterEventBus) MongoDatabase(com.mongodb.client.MongoDatabase) Before(org.junit.Before)

Example 7 with ChainingClassLoader

use of org.graylog2.shared.plugins.ChainingClassLoader 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;
}
Also used : PluginConfigBean(org.graylog2.plugin.PluginConfigBean) PluginBindings(org.graylog2.shared.bindings.PluginBindings) PluginModule(org.graylog2.plugin.PluginModule) Plugin(org.graylog2.plugin.Plugin)

Example 8 with ChainingClassLoader

use of org.graylog2.shared.plugins.ChainingClassLoader in project graylog2-server by Graylog2.

the class CmdLineTool method run.

@Override
public void run() {
    final Level logLevel = setupLogger();
    final PluginBindings pluginBindings = installPluginConfigAndBindings(getPluginPath(configFile), chainingClassLoader);
    if (isDumpDefaultConfig()) {
        dumpDefaultConfigAndExit();
    }
    final NamedConfigParametersModule configModule = readConfiguration(configFile);
    if (isDumpConfig()) {
        dumpCurrentConfigAndExit();
    }
    if (!validateConfiguration()) {
        LOG.error("Validating configuration file failed - exiting.");
        System.exit(1);
    }
    beforeStart();
    final List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
    LOG.info("Running with JVM arguments: {}", Joiner.on(' ').join(arguments));
    injector = setupInjector(configModule, pluginBindings, binder -> binder.bind(ChainingClassLoader.class).toInstance(chainingClassLoader));
    if (injector == null) {
        LOG.error("Injector could not be created, exiting! (Please include the previous error messages in bug reports.)");
        System.exit(1);
    }
    // This is holding all our metrics.
    final MetricRegistry metrics = injector.getInstance(MetricRegistry.class);
    addInstrumentedAppender(metrics, logLevel);
    // Report metrics via JMX.
    final JmxReporter reporter = JmxReporter.forRegistry(metrics).build();
    reporter.start();
    startCommand();
}
Also used : NamedConfigParametersModule(com.github.joschi.jadconfig.guice.NamedConfigParametersModule) Option(com.github.rvesse.airline.annotations.Option) Module(com.google.inject.Module) Plugin(org.graylog2.plugin.Plugin) Arrays(java.util.Arrays) ParameterException(com.github.joschi.jadconfig.ParameterException) NodeIdPersistenceException(org.graylog2.plugin.system.NodeIdPersistenceException) GuiceInjectorHolder(org.graylog2.shared.bindings.GuiceInjectorHolder) RepositoryException(com.github.joschi.jadconfig.RepositoryException) LoggerContext(org.apache.logging.log4j.core.LoggerContext) Tools(org.graylog2.plugin.Tools) LoggerFactory(org.slf4j.LoggerFactory) Level(org.apache.logging.log4j.Level) InstrumentedAppender(com.codahale.metrics.log4j2.InstrumentedAppender) Slf4JLoggerFactory(org.jboss.netty.logging.Slf4JLoggerFactory) Message(com.google.inject.spi.Message) PluginLoaderConfig(org.graylog2.plugin.PluginLoaderConfig) Map(java.util.Map) InternalLoggerFactory(org.jboss.netty.logging.InternalLoggerFactory) Version(org.graylog2.plugin.Version) JmxReporter(com.codahale.metrics.JmxReporter) PropertiesRepository(com.github.joschi.jadconfig.repositories.PropertiesRepository) Command(com.github.rvesse.airline.annotations.Command) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) PluginModule(org.graylog2.plugin.PluginModule) ExceptionUtils(org.graylog2.shared.utilities.ExceptionUtils) JodaTimeConverterFactory(com.github.joschi.jadconfig.jodatime.JodaTimeConverterFactory) Collection(java.util.Collection) Set(java.util.Set) ServerStatus(org.graylog2.plugin.ServerStatus) ValidationException(com.github.joschi.jadconfig.ValidationException) Sets(com.google.common.collect.Sets) List(java.util.List) PluginBindings(org.graylog2.shared.bindings.PluginBindings) PluginMetaData(org.graylog2.plugin.PluginMetaData) UI(org.graylog2.shared.UI) AccessDeniedException(java.nio.file.AccessDeniedException) GuavaConverterFactory(com.github.joschi.jadconfig.guava.GuavaConverterFactory) Joiner(com.google.common.base.Joiner) EnvironmentRepository(com.github.joschi.jadconfig.repositories.EnvironmentRepository) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Binder(com.google.inject.Binder) SystemPropertiesRepository(com.github.joschi.jadconfig.repositories.SystemPropertiesRepository) JadConfig(com.github.joschi.jadconfig.JadConfig) ManagementFactory(java.lang.management.ManagementFactory) NamedConfigParametersModule(com.github.joschi.jadconfig.guice.NamedConfigParametersModule) MetricRegistry(com.codahale.metrics.MetricRegistry) Logger(org.slf4j.Logger) PluginConfigBean(org.graylog2.plugin.PluginConfigBean) Names(com.google.inject.name.Names) PluginLoader(org.graylog2.shared.plugins.PluginLoader) File(java.io.File) Injector(com.google.inject.Injector) CreationException(com.google.inject.CreationException) Repository(com.github.joschi.jadconfig.Repository) BaseConfiguration(org.graylog2.plugin.BaseConfiguration) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) PluginBindings(org.graylog2.shared.bindings.PluginBindings) MetricRegistry(com.codahale.metrics.MetricRegistry) Level(org.apache.logging.log4j.Level) JmxReporter(com.codahale.metrics.JmxReporter) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader)

Example 9 with ChainingClassLoader

use of org.graylog2.shared.plugins.ChainingClassLoader in project graylog2-server by Graylog2.

the class MongoIndexSetServiceTest method setUp.

@Before
public void setUp() throws Exception {
    clusterEventBus = new ClusterEventBus();
    clusterConfigService = new ClusterConfigServiceImpl(objectMapperProvider, mongoRule.getMongoConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), clusterEventBus);
    indexSetService = new MongoIndexSetService(mongoRule.getMongoConnection(), objectMapperProvider, streamService, clusterConfigService, clusterEventBus);
}
Also used : ClusterConfigServiceImpl(org.graylog2.cluster.ClusterConfigServiceImpl) ClusterEventBus(org.graylog2.events.ClusterEventBus) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) Before(org.junit.Before)

Aggregations

ChainingClassLoader (org.graylog2.shared.plugins.ChainingClassLoader)6 Before (org.junit.Before)5 ClusterConfigServiceImpl (org.graylog2.cluster.ClusterConfigServiceImpl)3 ClusterEventBus (org.graylog2.events.ClusterEventBus)3 Plugin (org.graylog2.plugin.Plugin)3 ImmutableList (com.google.common.collect.ImmutableList)2 Module (com.google.inject.Module)2 File (java.io.File)2 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)2 PluginConfigBean (org.graylog2.plugin.PluginConfigBean)2 PluginModule (org.graylog2.plugin.PluginModule)2 PluginBindings (org.graylog2.shared.bindings.PluginBindings)2 JmxReporter (com.codahale.metrics.JmxReporter)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 InstrumentedAppender (com.codahale.metrics.log4j2.InstrumentedAppender)1 JadConfig (com.github.joschi.jadconfig.JadConfig)1 ParameterException (com.github.joschi.jadconfig.ParameterException)1 Repository (com.github.joschi.jadconfig.Repository)1 RepositoryException (com.github.joschi.jadconfig.RepositoryException)1 ValidationException (com.github.joschi.jadconfig.ValidationException)1