Search in sources :

Example 1 with InputCreated

use of org.graylog2.rest.models.system.inputs.responses.InputCreated in project graylog2-server by Graylog2.

the class InputEventListener method inputCreated.

@Subscribe
public void inputCreated(InputCreated inputCreatedEvent) {
    final String inputId = inputCreatedEvent.id();
    LOG.debug("Input created: {}", inputId);
    final Input input;
    try {
        input = inputService.find(inputId);
    } catch (NotFoundException e) {
        LOG.warn("Received InputCreated event but could not find input {}", inputId, e);
        return;
    }
    final IOState<MessageInput> inputState = inputRegistry.getInputState(inputId);
    if (inputState != null) {
        inputRegistry.remove(inputState);
    }
    if (input.isGlobal() || this.nodeId.toString().equals(input.getNodeId())) {
        startInput(input);
    }
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) NotFoundException(org.graylog2.database.NotFoundException) MessageInput(org.graylog2.plugin.inputs.MessageInput) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with InputCreated

use of org.graylog2.rest.models.system.inputs.responses.InputCreated in project graylog2-server by Graylog2.

the class InputStatesResource method start.

@PUT
@Path("/{inputId}")
@Timed
@ApiOperation(value = "(Re-)Start specified input on this node")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input on this node.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_INPUT_START)
public InputCreated start(@ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId) throws org.graylog2.database.NotFoundException {
    checkPermission(RestPermissions.INPUTS_CHANGESTATE, inputId);
    final Input input = inputService.find(inputId);
    persistDesiredState(input, IOState.Type.RUNNING);
    final InputCreated result = InputCreated.create(inputId);
    this.serverEventBus.post(result);
    return result;
}
Also used : Input(org.graylog2.inputs.Input) MessageInput(org.graylog2.plugin.inputs.MessageInput) InputCreated(org.graylog2.rest.models.system.inputs.responses.InputCreated) 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

MessageInput (org.graylog2.plugin.inputs.MessageInput)2 Timed (com.codahale.metrics.annotation.Timed)1 Subscribe (com.google.common.eventbus.Subscribe)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 AuditEvent (org.graylog2.audit.jersey.AuditEvent)1 NotFoundException (org.graylog2.database.NotFoundException)1 Input (org.graylog2.inputs.Input)1 InputCreated (org.graylog2.rest.models.system.inputs.responses.InputCreated)1