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;
}
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;
}
}
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;
}
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;
}
}
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;
}
Aggregations