Package org.graylog2.plugin.inputs

Examples of org.graylog2.plugin.inputs.MessageInput


    @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

            NotFoundException, org.graylog2.ConfigurationException, ExtractorFactory.NoSuchExtractorException,
            org.graylog2.plugin.inputs.Extractor.ReservedFieldException {
        final Configuration inputConfig = new Configuration(inputDescription.getConfiguration());
        final DateTime createdAt = Tools.iso8601();

        final MessageInput messageInput = inputRegistry.create(inputDescription.getType(), inputConfig);
        messageInput.setTitle(inputDescription.getTitle());
        messageInput.setGlobal(inputDescription.isGlobal());
        messageInput.setCreatorUserId(userName);
        messageInput.setCreatedAt(createdAt);
        messageInput.setContentPack(bundleId);

        messageInput.setConfiguration(inputConfig);
        messageInput.checkConfiguration();

        // Don't run if exclusive and another instance is already running.
        if (messageInput.isExclusive() && inputRegistry.hasTypeRunning(messageInput.getClass())) {
            final String error = "Type is exclusive and already has input running.";
            LOG.error(error);
        }

        org.graylog2.inputs.Input mongoInput = new InputImpl(
                buildMongoDbInput(UUID.randomUUID(), inputDescription, userName, createdAt, bundleId));

        // Persist input.
        final String persistId = inputService.save(mongoInput);
        messageInput.setPersistId(persistId);
        messageInput.initialize();

        addStaticFields(messageInput, inputDescription.getStaticFields());
        addExtractors(messageInput, inputDescription.getExtractors(), userName);

        return messageInput;
View Full Code Here

    protected List<MessageInput> getAllPersisted() {
        List<MessageInput> result = Lists.newArrayList();

        for (Input io : inputService.allOfThisNode(serverStatus.getNodeId().toString())) {
            MessageInput input = null;
            try {
                input = inputService.getMessageInput(io);
                result.add(input);
            } catch (NoSuchInputTypeException e) {
                LOG.warn("Cannot launch persisted input. No such type [{}].", io.getType());
View Full Code Here

        processBufferProcessors[0] = processBufferProcessor;

        processBuffer.initialize(processBufferProcessors, 1, new BlockingWaitStrategy(), 1);

        Message message = mock(Message.class);
        MessageInput messageInput = mock(MessageInput.class);

        processBuffer.insertFailFast(message, messageInput);
    }
View Full Code Here

    @Override
    public void insertFailFast(List<Message> messages) throws BufferOutOfCapacityException, ProcessingDisabledException {
        int length = messages.size();
        for (Message message : messages) {
            MessageInput sourceInput = message.getSourceInput();
            prepareMessage(message, sourceInput);
        }

        if (!serverStatus.isProcessing()) {
            LOG.debug("Rejecting message, because message processing is paused.");
View Full Code Here

    public InputState launch(final MessageInput input) {
        return launch(input, UUID.randomUUID().toString());
    }

    public InputState launch(final InputState inputState) {
        final MessageInput input = inputState.getMessageInput();

        return launch(input, inputState, false);
    }
View Full Code Here

    protected void shutDown() throws Exception {
        LOG.debug("Stopping InputSetupService");
        eventBus.unregister(this);

        for (InputState state : inputRegistry.getRunningInputs()) {
            MessageInput input = state.getMessageInput();

            LOG.info("Attempting to close input <{}> [{}].", input.getUniqueReadableId(), input.getName());

            Stopwatch s = Stopwatch.createStarted();
            try {
                input.stop();

                LOG.info("Input <{}> closed. Took [{}ms]", input.getUniqueReadableId(), s.elapsed(TimeUnit.MILLISECONDS));
            } catch (Exception e) {
                LOG.error("Unable to stop input <{}> [{}]: " + e.getMessage(), input.getUniqueReadableId(), input.getName());
            } finally {
                s.stop();
            }
        }
        LOG.debug("Stopped InputSetupService");
View Full Code Here

TOP

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

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.