use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.
the class ExtractorsResource method single.
@GET
@Timed
@ApiOperation(value = "Get information of a single extractor of an input")
@Path("/{extractorId}")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input on this node."), @ApiResponse(code = 404, message = "No such extractor on this input.") })
@Produces(MediaType.APPLICATION_JSON)
public ExtractorSummary single(@ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId, @ApiParam(name = "extractorId", required = true) @PathParam("extractorId") final String extractorId) throws NotFoundException {
checkPermission(RestPermissions.INPUTS_READ, inputId);
final MessageInput input = persistedInputs.get(inputId);
if (input == null) {
LOG.error("Input <{}> not found.", inputId);
throw new javax.ws.rs.NotFoundException("Couldn't find input " + inputId);
}
final Input mongoInput = inputService.find(input.getPersistId());
final Extractor extractor = inputService.getExtractor(mongoInput, extractorId);
return toSummary(extractor);
}
use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.
the class ExtractorsResource method terminate.
@DELETE
@Timed
@ApiOperation(value = "Delete an extractor")
@Path("/{extractorId}")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request."), @ApiResponse(code = 404, message = "Input not found."), @ApiResponse(code = 404, message = "Extractor not found.") })
@Produces(MediaType.APPLICATION_JSON)
@AuditEvent(type = AuditEventTypes.EXTRACTOR_DELETE)
public void terminate(@ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId, @ApiParam(name = "extractorId", required = true) @PathParam("extractorId") String extractorId) throws NotFoundException {
checkPermission(RestPermissions.INPUTS_EDIT, inputId);
final MessageInput input = persistedInputs.get(inputId);
if (input == null) {
LOG.error("Input <{}> not found.", inputId);
throw new javax.ws.rs.NotFoundException("Couldn't find input " + inputId);
}
// Remove from Mongo.
final Input mongoInput = inputService.find(input.getPersistId());
final Extractor extractor = inputService.getExtractor(mongoInput, extractorId);
inputService.removeExtractor(mongoInput, extractor.getId());
final String msg = "Deleted extractor <" + extractorId + "> of type [" + extractor.getType() + "] " + "from input <" + inputId + ">.";
LOG.info(msg);
activityWriter.write(new Activity(msg, InputsResource.class));
}
use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.
the class PersistedInputsImpl method iterator.
@Override
public Iterator<MessageInput> iterator() {
List<MessageInput> result = Lists.newArrayList();
for (Input io : inputService.allOfThisNode(serverStatus.getNodeId().toString())) {
try {
final MessageInput input = inputService.getMessageInput(io);
result.add(input);
} catch (NoSuchInputTypeException e) {
LOG.warn("Cannot instantiate persisted input. No such type [{}].", io.getType());
} catch (Throwable e) {
LOG.warn("Cannot instantiate persisted input. Exception caught: ", e);
}
}
return result.iterator();
}
use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.
the class TcpTransport method getCustomChildChannelHandlers.
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getCustomChildChannelHandlers(MessageInput input) {
final LinkedHashMap<String, Callable<? extends ChannelHandler>> childChannelHandlers = new LinkedHashMap<>();
childChannelHandlers.put("framer", () -> new LenientDelimiterBasedFrameDecoder(maxFrameLength, delimiter));
childChannelHandlers.putAll(super.getCustomChildChannelHandlers(input));
return childChannelHandlers;
}
use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.
the class UdpTransport method getBootstrap.
@VisibleForTesting
Bootstrap getBootstrap(MessageInput input) {
LOG.debug("Setting UDP receive buffer size to {} bytes", getRecvBufferSize());
final NettyTransportType transportType = nettyTransportConfiguration.getType();
eventLoopGroup = eventLoopGroupFactory.create(workerThreads, localRegistry, "workers");
return new Bootstrap().group(eventLoopGroup).channelFactory(new DatagramChannelFactory(transportType)).option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(getRecvBufferSize())).option(ChannelOption.SO_RCVBUF, getRecvBufferSize()).option(UnixChannelOption.SO_REUSEPORT, true).handler(getChannelInitializer(getChannelHandlers(input))).validate();
}
Aggregations