Search in sources :

Example 21 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class Server method getCommandBindings.

@Override
protected List<Module> getCommandBindings() {
    final ImmutableList.Builder<Module> modules = ImmutableList.builder();
    modules.add(new ConfigurationModule(configuration), new ServerBindings(configuration), new PersistenceServicesBindings(), new MessageFilterBindings(), new MessageProcessorModule(), new AlarmCallbackBindings(), new InitializerBindings(), new MessageOutputBindings(configuration, chainingClassLoader), new RotationStrategyBindings(), new RetentionStrategyBindings(), new PeriodicalBindings(), new ObjectMapperModule(chainingClassLoader), new RestApiBindings(), new PasswordAlgorithmBindings(), new WidgetStrategyBindings(), new DashboardBindings(), new DecoratorBindings(), new AuditBindings(), new AlertConditionBindings(), new IndexerBindings(), new MigrationsModule());
    return modules.build();
}
Also used : IndexerBindings(org.graylog2.indexer.IndexerBindings) PersistenceServicesBindings(org.graylog2.bindings.PersistenceServicesBindings) ImmutableList(com.google.common.collect.ImmutableList) ServerBindings(org.graylog2.bindings.ServerBindings) DecoratorBindings(org.graylog2.decorators.DecoratorBindings) ConfigurationModule(org.graylog2.bindings.ConfigurationModule) AlarmCallbackBindings(org.graylog2.bindings.AlarmCallbackBindings) ObjectMapperModule(org.graylog2.shared.bindings.ObjectMapperModule) MessageFilterBindings(org.graylog2.bindings.MessageFilterBindings) MessageProcessorModule(org.graylog2.messageprocessors.MessageProcessorModule) MessageOutputBindings(org.graylog2.bindings.MessageOutputBindings) AlertConditionBindings(org.graylog2.alerts.AlertConditionBindings) InitializerBindings(org.graylog2.bindings.InitializerBindings) WidgetStrategyBindings(org.graylog2.bindings.WidgetStrategyBindings) RotationStrategyBindings(org.graylog2.indexer.rotation.RotationStrategyBindings) AuditBindings(org.graylog2.audit.AuditBindings) DashboardBindings(org.graylog2.dashboards.DashboardBindings) Module(com.google.inject.Module) ConfigurationModule(org.graylog2.bindings.ConfigurationModule) MessageProcessorModule(org.graylog2.messageprocessors.MessageProcessorModule) ObjectMapperModule(org.graylog2.shared.bindings.ObjectMapperModule) MigrationsModule(org.graylog2.migrations.MigrationsModule) RetentionStrategyBindings(org.graylog2.indexer.retention.RetentionStrategyBindings) MigrationsModule(org.graylog2.migrations.MigrationsModule) PasswordAlgorithmBindings(org.graylog2.bindings.PasswordAlgorithmBindings) PeriodicalBindings(org.graylog2.bindings.PeriodicalBindings) RestApiBindings(org.graylog2.shared.bindings.RestApiBindings)

Example 22 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class ExposedConfigurationTest method testCreateWithConfiguration.

@Test
public void testCreateWithConfiguration() throws Exception {
    final Configuration configuration = new Configuration();
    final ExposedConfiguration c = ExposedConfiguration.create(configuration);
    assertThat(c.inputBufferProcessors()).isEqualTo(configuration.getInputbufferProcessors());
    assertThat(c.processBufferProcessors()).isEqualTo(configuration.getProcessBufferProcessors());
    assertThat(c.outputBufferProcessors()).isEqualTo(configuration.getOutputBufferProcessors());
    assertThat(c.processorWaitStrategy()).isEqualTo(configuration.getProcessorWaitStrategy().getClass().getName());
    assertThat(c.inputBufferWaitStrategy()).isEqualTo(configuration.getInputBufferWaitStrategy().getClass().getName());
    assertThat(c.inputBufferRingSize()).isEqualTo(configuration.getInputBufferRingSize());
    assertThat(c.ringSize()).isEqualTo(configuration.getRingSize());
    assertThat(c.pluginDir()).isEqualTo(configuration.getPluginDir());
    assertThat(c.nodeIdFile()).isEqualTo(configuration.getNodeIdFile());
    assertThat(c.allowHighlighting()).isEqualTo(configuration.isAllowHighlighting());
    assertThat(c.allowLeadingWildcardSearches()).isEqualTo(configuration.isAllowLeadingWildcardSearches());
    assertThat(c.streamProcessingTimeout()).isEqualTo(configuration.getStreamProcessingTimeout());
    assertThat(c.streamProcessingMaxFaults()).isEqualTo(configuration.getStreamProcessingMaxFaults());
    assertThat(c.outputModuleTimeout()).isEqualTo(configuration.getOutputModuleTimeout());
    assertThat(c.staleMasterTimeout()).isEqualTo(configuration.getStaleMasterTimeout());
    assertThat(c.gcWarningThreshold()).isEqualTo(configuration.getGcWarningThreshold().toString());
}
Also used : Configuration(org.graylog2.Configuration) Test(org.junit.Test)

Example 23 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class ExposedConfigurationTest method testSerialization.

@Test
public void testSerialization() throws Exception {
    final Configuration configuration = new Configuration();
    final ExposedConfiguration c = ExposedConfiguration.create(configuration);
    final String json = objectMapper.writeValueAsString(c);
    assertThat((int) JsonPath.read(json, "$.inputbuffer_processors")).isEqualTo(c.inputBufferProcessors());
    assertThat((int) JsonPath.read(json, "$.processbuffer_processors")).isEqualTo(c.processBufferProcessors());
    assertThat((int) JsonPath.read(json, "$.outputbuffer_processors")).isEqualTo(c.outputBufferProcessors());
    assertThat((String) JsonPath.read(json, "$.processor_wait_strategy")).isEqualTo(c.processorWaitStrategy());
    assertThat((String) JsonPath.read(json, "$.inputbuffer_wait_strategy")).isEqualTo(c.inputBufferWaitStrategy());
    assertThat((int) JsonPath.read(json, "$.inputbuffer_ring_size")).isEqualTo(c.inputBufferRingSize());
    assertThat((int) JsonPath.read(json, "$.ring_size")).isEqualTo(c.ringSize());
    assertThat((String) JsonPath.read(json, "$.plugin_dir")).isEqualTo(c.pluginDir());
    assertThat((String) JsonPath.read(json, "$.node_id_file")).isEqualTo(c.nodeIdFile());
    assertThat((boolean) JsonPath.read(json, "$.allow_highlighting")).isEqualTo(c.allowHighlighting());
    assertThat((boolean) JsonPath.read(json, "$.allow_leading_wildcard_searches")).isEqualTo(c.allowLeadingWildcardSearches());
    assertThat((int) JsonPath.read(json, "$.stream_processing_timeout")).isEqualTo((int) c.streamProcessingTimeout());
    assertThat((int) JsonPath.read(json, "$.stream_processing_max_faults")).isEqualTo(c.streamProcessingMaxFaults());
    assertThat((int) JsonPath.read(json, "$.output_module_timeout")).isEqualTo((int) c.outputModuleTimeout());
    assertThat((int) JsonPath.read(json, "$.stale_master_timeout")).isEqualTo(c.staleMasterTimeout());
    assertThat((String) JsonPath.read(json, "$.gc_warning_threshold")).isEqualTo(c.gcWarningThreshold());
}
Also used : Configuration(org.graylog2.Configuration) Test(org.junit.Test)

Example 24 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class MessageProcessorsResource method config.

@GET
@Timed
@ApiOperation(value = "Get message processor configuration")
@Path("config")
public MessageProcessorsConfigWithDescriptors config() {
    checkPermission(RestPermissions.CLUSTER_CONFIG_ENTRY_READ);
    final MessageProcessorsConfig config = clusterConfigService.getOrDefault(MessageProcessorsConfig.class, MessageProcessorsConfig.defaultConfig());
    return MessageProcessorsConfigWithDescriptors.fromConfig(config.withProcessors(processorClassNames), processorDescriptors);
}
Also used : MessageProcessorsConfig(org.graylog2.messageprocessors.MessageProcessorsConfig) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 25 with Configuration

use of org.graylog2.Configuration in project graylog2-server by Graylog2.

the class IndexSetsResource method update.

@PUT
@Path("{id}")
@Timed
@ApiOperation(value = "Update index set")
@AuditEvent(type = AuditEventTypes.INDEX_SET_UPDATE)
@ApiResponses(value = { @ApiResponse(code = 403, message = "Unauthorized"), @ApiResponse(code = 409, message = "Mismatch of IDs in URI path and payload") })
public IndexSetSummary update(@ApiParam(name = "id", required = true) @PathParam("id") String id, @ApiParam(name = "Index set configuration", required = true) @Valid @NotNull IndexSetUpdateRequest updateRequest) {
    checkPermission(RestPermissions.INDEXSETS_EDIT, id);
    final IndexSetConfig oldConfig = indexSetService.get(id).orElseThrow(() -> new NotFoundException("Index set <" + id + "> not found"));
    final IndexSetConfig defaultIndexSet = indexSetService.getDefault();
    final boolean isDefaultSet = oldConfig.equals(defaultIndexSet);
    if (isDefaultSet && !updateRequest.isWritable()) {
        throw new ClientErrorException("Default index set must be writable.", Response.Status.CONFLICT);
    }
    final IndexSetConfig savedObject = indexSetService.save(updateRequest.toIndexSetConfig(id, oldConfig));
    return IndexSetSummary.fromIndexSetConfig(savedObject, isDefaultSet);
}
Also used : IndexSetConfig(org.graylog2.indexer.indexset.IndexSetConfig) DefaultIndexSetConfig(org.graylog2.indexer.indexset.DefaultIndexSetConfig) NotFoundException(javax.ws.rs.NotFoundException) ClientErrorException(javax.ws.rs.ClientErrorException) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) AuditEvent(org.graylog2.audit.jersey.AuditEvent) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Test (org.junit.Test)36 Configuration (org.graylog2.plugin.configuration.Configuration)29 ApiOperation (io.swagger.annotations.ApiOperation)24 Timed (com.codahale.metrics.annotation.Timed)23 BadRequestException (javax.ws.rs.BadRequestException)19 Path (javax.ws.rs.Path)18 AuditEvent (org.graylog2.audit.jersey.AuditEvent)17 Consumes (javax.ws.rs.Consumes)13 AlertCondition (org.graylog2.plugin.alarms.AlertCondition)13 MessageInput (org.graylog2.plugin.inputs.MessageInput)13 Stream (org.graylog2.plugin.streams.Stream)13 ApiResponses (io.swagger.annotations.ApiResponses)12 PUT (javax.ws.rs.PUT)11 ValidationException (org.graylog2.plugin.database.ValidationException)11 DateTime (org.joda.time.DateTime)11 Produces (javax.ws.rs.Produces)10 Configuration (org.graylog2.Configuration)10 POST (javax.ws.rs.POST)9 EmailConfiguration (org.graylog2.configuration.EmailConfiguration)9 URI (java.net.URI)8