Package org.graylog2.plugin.inputs

Examples of org.graylog2.plugin.inputs.MessageInput$Config


    @DELETE
    @Timed
    @Path("/{inputId}")
    public Response terminate(@PathParam("inputId") String inputId) {
        MessageInput input = inputRegistry.getRunningInput(inputId);

        if (input == null) {
            LOG.info("Cannot terminate input. Input not found.");
            throw new NotFoundException();
        }

        LOG.info("Attempting to terminate input [" + input.getName() + "]. Reason: REST request.");
        inputRegistry.terminate(input);
        LOG.info("Terminated input [" + input.getName() + "]. Reason: REST request.");

        return Response.accepted().build();
    }
View Full Code Here


    @Timed
    @Path("/{inputId}/launch")
    public Response launchExisting(@PathParam("inputId") String inputId) {
        final InputState inputState = inputRegistry.getInputState(inputId);

        final MessageInput input;
        if (inputState == null) {
            input = inputRegistry.getPersisted(inputId);
        } else {
            input = inputState.getMessageInput();
        }

        if (input == null) {
            final String message = "Cannot launch input <" + inputId + ">. Input not found.";
            LOG.info(message);
            throw new NotFoundException(message);
        }

        LOG.info("Launching existing input [" + input.getName() + "]. Reason: REST request.");
        input.initialize();
        if (inputState != null) {
            inputRegistry.launch(inputState);
        } else {
            inputRegistry.launchPersisted(input);
        }
        LOG.info("Launched existing input [" + input.getName() + "]. Reason: REST request.");

        final Map<String, String> result = ImmutableMap.of(
                "input_id", inputId,
                "persist_id", inputId);
View Full Code Here

    @POST
    @Timed
    @Path("/{inputId}/stop")
    public Response stop(@PathParam("inputId") String inputId) {
        final MessageInput input = inputRegistry.getRunningInput(inputId);
        if (input == null) {
            LOG.info("Cannot stop input. Input not found.");
            throw new NotFoundException();
        }

        LOG.info("Stopping input [" + input.getName() + "]. Reason: REST request.");
        inputRegistry.stop(input);
        LOG.info("Stopped input [" + input.getName() + "]. Reason: REST request.");

        return Response.accepted().build();
    }
View Full Code Here

        this.serverUrl = serverUrl;
        this.inputService = inputService;
    }

    private MessageInput getMessageInput(InputSummaryResponse isr) {
        MessageInput input;
        try {
            Configuration inputConfig = new Configuration(isr.configuration);
            input = this.create(isr.type, inputConfig);

            // Add all standard fields.
            input.setTitle(isr.title);
            input.setCreatorUserId(isr.creatorUserId);
            input.setPersistId(isr.id);
            input.setCreatedAt(new DateTime(isr.createdAt, DateTimeZone.UTC));
            input.setGlobal(isr.global);
            input.setConfiguration(inputConfig);

            input.checkConfiguration();
        } catch (NoSuchInputTypeException e) {
            LOG.warn("Cannot launch persisted input. No such type [{}]. Error: {}", isr.type, e);
            return null;
        } catch (ConfigurationException e) {
            LOG.error("Missing or invalid input input configuration.", e);
View Full Code Here

            LOG.error("Unable to get persisted inputs: ", e);
            return result;
        }

        for (InputSummaryResponse isr : response) {
            final MessageInput messageInput = getMessageInput(isr);
            if (messageInput != null) {
                LOG.debug("Loaded message input {}", messageInput);
                result.add(messageInput);
            }
        }
View Full Code Here

    public void cleanInput(MessageInput input) {
    }

    @Override
    protected void finishedTermination(InputState state) {
        MessageInput input = state.getMessageInput();
        try {
            if (!state.getMessageInput().getGlobal())
                inputService.unregisterInCluster(input);
        } catch (Exception e) {
            LOG.error("Could not unregister input [{}], id <{}> on server cluster: {}", input.getName(), input.getId(), e);
            return;
        }

        LOG.info("Unregistered input [{}], id <{}> on server cluster.", input.getName(), input.getId());

        removeFromRunning(state);
    }
View Full Code Here

    @Test
    public void testGetAndSetSourceInput() throws Exception {
        assertNull(message.getSourceInput());

        final MessageInput input = mock(MessageInput.class);

        message.setSourceInput(input);

        assertEquals(input, message.getSourceInput());
    }
View Full Code Here

    }

    @Override
    public MessageInput buildMessageInput(Input io) throws NoSuchInputTypeException {
        final Configuration configuration = new Configuration(io.getConfiguration());
        final MessageInput input = messageInputFactory.create(io.getType(), configuration);

        // Add all standard fields.
        input.setTitle(io.getTitle());
        input.setCreatorUserId(io.getCreatorUserId());
        input.setPersistId(io.getId());
        input.setCreatedAt(io.getCreatedAt());
        input.setContentPack(io.getContentPack());

        if (io.isGlobal()) {
            input.setGlobal(true);
        }

        // Add static fields.
        input.addStaticFields(io.getStaticFields());

        input.setConfiguration(configuration);

        return input;
    }
View Full Code Here

    }

    private void deleteCreatedInputs() throws NotFoundException {
        for (Map.Entry<String, MessageInput> entry : createdInputs.entrySet()) {
            final String inputId = entry.getKey();
            final MessageInput messageInput = entry.getValue();

            LOG.debug("Terminating message input {}", inputId);
            inputRegistry.terminate(messageInput);
            inputRegistry.cleanInput(messageInput);
        }
View Full Code Here

    }

    private void createInputs(final String bundleId, final List<Input> inputs, final String userName)
            throws org.graylog2.plugin.inputs.Extractor.ReservedFieldException, org.graylog2.ConfigurationException, NoSuchInputTypeException, ValidationException, ExtractorFactory.NoSuchExtractorException, NotFoundException, ConfigurationException {
        for (final Input input : inputs) {
            final MessageInput messageInput = createMessageInput(bundleId, input, userName);
            createdInputs.put(messageInput.getId(), messageInput);

            // Launch input. (this will run async and clean up itself in case of an error.)
            inputRegistry.launch(messageInput, messageInput.getId());
        }
    }
View Full Code Here

TOP

Related Classes of org.graylog2.plugin.inputs.MessageInput$Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.