Search in sources :

Example 1 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class SyslogTcpTransport method getFinalChannelHandlers.

@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getFinalChannelHandlers(MessageInput input) {
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> finalChannelHandlers = Maps.newLinkedHashMap();
    finalChannelHandlers.putAll(super.getFinalChannelHandlers(input));
    // Replace the "framer" channel handler inserted by the parent.
    finalChannelHandlers.put("framer", new Callable<ChannelHandler>() {

        @Override
        public ChannelHandler call() throws Exception {
            return new SyslogTCPFramingRouterHandler(maxFrameLength, delimiter);
        }
    });
    return finalChannelHandlers;
}
Also used : SyslogTCPFramingRouterHandler(org.graylog2.inputs.syslog.tcp.SyslogTCPFramingRouterHandler) ChannelHandler(org.jboss.netty.channel.ChannelHandler) Callable(java.util.concurrent.Callable)

Example 2 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class PersistedInputsImpl method add.

@Override
public boolean add(MessageInput input) {
    try {
        final Input mongoInput = getInput(input);
        // Persist input.
        String id = inputService.save(mongoInput);
        input.setPersistId(id);
        return true;
    } catch (ValidationException e) {
        return false;
    }
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) ValidationException(org.graylog2.plugin.database.ValidationException)

Example 3 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class PersistedInputsImpl method remove.

@Override
public boolean remove(Object o) {
    if (o instanceof MessageInput) {
        final MessageInput messageInput = (MessageInput) o;
        if (isNullOrEmpty(messageInput.getId()))
            return false;
        try {
            final Input input = inputService.find(messageInput.getId());
            inputService.destroy(input);
            return true;
        } catch (NotFoundException e) {
            return false;
        }
    }
    return false;
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) NotFoundException(org.graylog2.database.NotFoundException)

Example 4 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class PersistedInputsImpl method update.

@Override
public boolean update(String id, MessageInput newInput) {
    try {
        final Input oldInput = inputService.find(id);
        newInput.setPersistId(id);
        final Input mongoInput = getInput(newInput);
        final List<Extractor> extractors = inputService.getExtractors(oldInput);
        final Map<String, String> staticFields = oldInput.getStaticFields();
        inputService.save(mongoInput);
        for (Map.Entry<String, String> entry : staticFields.entrySet()) inputService.addStaticField(mongoInput, entry.getKey(), entry.getValue());
        for (Extractor extractor : extractors) inputService.addExtractor(mongoInput, extractor);
        return true;
    } catch (NotFoundException | ValidationException e) {
        return false;
    }
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) ValidationException(org.graylog2.plugin.database.ValidationException) NotFoundException(org.graylog2.database.NotFoundException) Extractor(org.graylog2.plugin.inputs.Extractor) Map(java.util.Map)

Example 5 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class PersistedInputsImpl method getInput.

private Input getInput(MessageInput input) throws ValidationException {
    // Build MongoDB data
    final Map<String, Object> inputData = input.asMap();
    // ... and check if it would pass validation. We don't need to go on if it doesn't.
    final Input mongoInput;
    if (input.getId() != null)
        mongoInput = inputService.create(input.getId(), inputData);
    else
        mongoInput = inputService.create(inputData);
    return mongoInput;
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput)

Aggregations

MessageInput (org.graylog2.plugin.inputs.MessageInput)47 Test (org.junit.Test)18 Callable (java.util.concurrent.Callable)17 NotFoundException (org.graylog2.database.NotFoundException)10 Configuration (org.graylog2.plugin.configuration.Configuration)9 ChannelHandler (io.netty.channel.ChannelHandler)8 LinkedHashMap (java.util.LinkedHashMap)8 Input (org.graylog2.inputs.Input)8 MisfireException (org.graylog2.plugin.inputs.MisfireException)7 ChannelHandler (org.jboss.netty.channel.ChannelHandler)7 Timed (com.codahale.metrics.annotation.Timed)6 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 EventBus (com.google.common.eventbus.EventBus)5 AuditEvent (org.graylog2.audit.jersey.AuditEvent)5 Subscribe (com.google.common.eventbus.Subscribe)4 Produces (javax.ws.rs.Produces)4 IOState (org.graylog2.plugin.IOState)4 LocalMetricRegistry (org.graylog2.plugin.LocalMetricRegistry)4 Extractor (org.graylog2.plugin.inputs.Extractor)4