Search in sources :

Example 16 with ConfigurationRequest

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

the class GelfOutputTest method testGetRequestedConfiguration.

@Test
public void testGetRequestedConfiguration() throws Exception {
    final GelfOutput.Config gelfOutputConfig = new GelfOutput.Config();
    final ConfigurationRequest request = gelfOutputConfig.getRequestedConfiguration();
    assertNotNull(request);
    assertNotNull(request.asList());
}
Also used : ConfigurationRequest(org.graylog2.plugin.configuration.ConfigurationRequest) Test(org.junit.Test)

Example 17 with ConfigurationRequest

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

the class UdpTransportTest method testDefaultReceiveBufferSize.

@Test
public void testDefaultReceiveBufferSize() throws Exception {
    final UdpTransport.Config config = new UdpTransport.Config();
    final ConfigurationRequest requestedConfiguration = config.getRequestedConfiguration();
    assertThat(requestedConfiguration.getField(NettyTransport.CK_RECV_BUFFER_SIZE).getDefaultValue()).isEqualTo(262144);
}
Also used : ConfigurationRequest(org.graylog2.plugin.configuration.ConfigurationRequest) Test(org.junit.Test)

Example 18 with ConfigurationRequest

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

the class AlertConditionFactory method createAlertCondition.

public AlertCondition createAlertCondition(String type, Stream stream, String id, DateTime createdAt, String creatorId, Map<String, Object> parameters, String title) throws ConfigurationException {
    final AlertCondition.Factory factory = this.alertConditionMap.get(type);
    checkArgument(factory != null, "Unknown alert condition type: " + type);
    /*
         * Ensure the given parameters fulfill the requested configuration preconditions.
         * Here we strictly use the Configuration object to verify the configuration and don't pass it down to
         * the factory. The reason for this is that Configuration only support int values, but at least an
         * alert condition expects a double.
         */
    try {
        final ConfigurationRequest requestedConfiguration = factory.config().getRequestedConfiguration();
        final Configuration configuration = new Configuration(parameters);
        requestedConfiguration.check(configuration);
    } catch (ConfigurationException e) {
        final String conditionTitle = isNullOrEmpty(title) ? "" : "'" + title + "' ";
        LOG.error("Could not load alert condition " + conditionTitle + "<" + id + ">, invalid configuration detected.");
        throw e;
    }
    return factory.create(stream, id, createdAt, creatorId, parameters, title);
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) ConfigurationException(org.graylog2.plugin.configuration.ConfigurationException) ConfigurationRequest(org.graylog2.plugin.configuration.ConfigurationRequest) AlertCondition(org.graylog2.plugin.alarms.AlertCondition)

Aggregations

ConfigurationRequest (org.graylog2.plugin.configuration.ConfigurationRequest)18 Test (org.junit.Test)11 AlertCondition (org.graylog2.plugin.alarms.AlertCondition)4 HashMap (java.util.HashMap)3 TextField (org.graylog2.plugin.configuration.fields.TextField)3 ValidationException (org.graylog2.plugin.database.ValidationException)3 BadRequestException (javax.ws.rs.BadRequestException)2 AlarmCallbackConfiguration (org.graylog2.alarmcallbacks.AlarmCallbackConfiguration)2 ConfigurationField (org.graylog2.plugin.configuration.fields.ConfigurationField)2 Stream (org.graylog2.plugin.streams.Stream)2 CreateAlarmCallbackRequest (org.graylog2.rest.models.alarmcallbacks.requests.CreateAlarmCallbackRequest)2 Maps (com.google.common.collect.Maps)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 EmailAlarmCallback (org.graylog2.alarmcallbacks.EmailAlarmCallback)1 AlarmCallback (org.graylog2.plugin.alarms.callbacks.AlarmCallback)1 Configuration (org.graylog2.plugin.configuration.Configuration)1