Package org.graylog2.plugin.outputs

Examples of org.graylog2.plugin.outputs.MessageOutput


    // This is so ugly!
    // TODO: Remove this once we implemented proper types for input/ouput configuration.
    private Map<String, Object> filterPasswordFields(final Output output) {
        final Map<String, Object> data = output.asMap();
        final MessageOutput messageOutput = messageOutputFactory.fromStreamOutput(output);

        if (messageOutput == null) {
            return data;
        }

        final ConfigurationRequest requestedConfiguration = messageOutput.getRequestedConfiguration();

        if (data.containsKey("configuration")) {
            final Map<String, Object> c = (Map<String, Object>) data.get("configuration");

            for (Map.Entry<String, Object> entry : c.entrySet()) {
View Full Code Here


    protected void register(String id, MessageOutput output) {
        this.runningMessageOutputs.put(id, output);
    }

    protected MessageOutput launchOutput(Output output) throws MessageOutputConfigurationException {
        final MessageOutput messageOutput = messageOutputFactory.fromStreamOutput(output);
        if (messageOutput == null)
            throw new IllegalArgumentException("Failed to instantiate MessageOutput from Output: " + output);

        messageOutput.initialize(new Configuration(output.getConfiguration()));

        return messageOutput;
    }
View Full Code Here

        this.instantiationService = instantiationService;
    }

    public MessageOutput fromStreamOutput(Output output) {
        final Class<? extends MessageOutput> messageOutputClass = findMessageOutputClassForStreamOutput(output.getType());
        final MessageOutput messageOutput = instantiationService.getInstance(messageOutputClass);

        return messageOutput;
    }
View Full Code Here

    public Map<String, AvailableOutputSummary> getAvailableOutputs() {
        Map<String, AvailableOutputSummary> result = new HashMap<>();

        for (Class<? extends MessageOutput> messageOutputClass : availableMessageOutputClasses) {
            MessageOutput messageOutput = instantiationService.getInstance(messageOutputClass);
            AvailableOutputSummary availableOutputSummary = new AvailableOutputSummary();
            availableOutputSummary.requestedConfiguration = messageOutput.getRequestedConfiguration();
            availableOutputSummary.name = messageOutput.getName();
            availableOutputSummary.type = messageOutput.getClass().getCanonicalName();
            availableOutputSummary.humanName = messageOutput.getHumanName();
            availableOutputSummary.linkToDocs = messageOutput.getLinkToDocs();
            result.put(messageOutputClass.getCanonicalName(), availableOutputSummary);
        }

        return result;
    }
View Full Code Here

    }

    protected Set<MessageOutput> getMessageOutputsForStream(Stream stream) {
        Set<MessageOutput> result = new HashSet<>();
        for (Output output : stream.getOutputs()) {
            final MessageOutput messageOutput = outputRegistry.getOutputForId(output.getId());
            if (messageOutput != null)
                result.add(messageOutput);
        }

        return result;
View Full Code Here

    public void testGetMessageOutputsForSingleStream() throws Exception {
        final Stream stream = mock(Stream.class);
        final Output output = mock(Output.class);
        final String outputId = "foobar";
        final MessageOutput messageOutput = mock(MessageOutput.class);
        final Set<Output> outputSet = new HashSet<Output>() {{ add(output); }};
        when(stream.getOutputs()).thenReturn(outputSet);
        when(output.getId()).thenReturn(outputId);
        when(outputRegistry.getOutputForId(eq(outputId))).thenReturn(messageOutput);
        final OutputRouter outputRouter = new OutputRouter(defaultMessageOutput, outputRegistry);
View Full Code Here

        final Stream stream = mock(Stream.class);
        final Output output1 = mock(Output.class);
        final Output output2 = mock(Output.class);
        final String output1Id = "foo";
        final String output2Id = "bar";
        final MessageOutput messageOutput1 = mock(MessageOutput.class);
        final MessageOutput messageOutput2 = mock(MessageOutput.class);
        final Set<Output> outputSet = new HashSet<Output>() {{ add(output1); add(output2); }};
        when(stream.getOutputs()).thenReturn(outputSet);
        when(output1.getId()).thenReturn(output1Id);
        when(output2.getId()).thenReturn(output2Id);
        when(outputRegistry.getOutputForId(eq(output1Id))).thenReturn(messageOutput1);
View Full Code Here

            add(stream);
        }};
        final Message message = mock(Message.class);
        when(message.getStreams()).thenReturn(streamList);

        final MessageOutput messageOutput = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputList = new HashSet<MessageOutput>() {{ add(messageOutput); }};

        final OutputRouter outputRouter = Mockito.spy(new OutputRouter(defaultMessageOutput, outputRegistry));
        doReturn(messageOutputList).when(outputRouter).getMessageOutputsForStream(eq(stream));
View Full Code Here

    }

    public void testGetOutputsFromTwoStreams() throws Exception {
        final Stream stream1 = mock(Stream.class);
        final Stream stream2 = mock(Stream.class);
        final MessageOutput messageOutput1 = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputSet1 = new HashSet<MessageOutput>() {{ add(messageOutput1); }};
        final MessageOutput messageOutput2 = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputSet2 = new HashSet<MessageOutput>() {{ add(messageOutput2); }};
        final Message message = mock(Message.class);
        final List<Stream> streamList = new ArrayList<Stream>() {{ add(stream1); add(stream2); }};
        when(message.getStreams()).thenReturn(streamList);
View Full Code Here

    @Test
    public void testGetOutputsWithIdenticalMessageOutputs() throws Exception {
        final Stream stream1 = mock(Stream.class);
        final Stream stream2 = mock(Stream.class);
        final MessageOutput messageOutput = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputSet = new HashSet<MessageOutput>() {{ add(messageOutput); }};
        final Message message = mock(Message.class);
        final List<Stream> streamList = new ArrayList<Stream>() {{ add(stream1); add(stream2); }};
        when(message.getStreams()).thenReturn(streamList);
View Full Code Here

TOP

Related Classes of org.graylog2.plugin.outputs.MessageOutput

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.