Package org.graylog2.plugin

Examples of org.graylog2.plugin.Message


                Integer backlogSize = getBacklog();
                if (backlogSize != null && backlogSize > 0) {
                    SearchResult backlogResult = searches.search("*", filter, new RelativeRange(time * 60), backlogSize, 0, new Sorting("timestamp", Sorting.Direction.DESC));
                    this.searchHits = Lists.newArrayList();
                    for (ResultMessage resultMessage : backlogResult.getResults()) {
                        searchHits.add(new Message(resultMessage.getMessage()));
                    }
                }

                final String resultDescription = "Stream had " + count + " messages in the last " + time
                        + " minutes with trigger condition " + thresholdType.toString().toLowerCase()
View Full Code Here


          throw new WebApplicationException(400);
        }
        checkPermission(RestPermissions.MESSAGES_READ, messageId);
    try {
            ResultMessage resultMessage = messages.get(messageId, index);
            Message message = new Message(resultMessage.getMessage());
            checkMessageReadPermission(message);

            return json(resultMessage);
    } catch (IndexMissingException e) {
          LOG.error("Index {} does not exist. Returning HTTP 404.", e.index().name());
View Full Code Here

        }

        outputBufferWatermark.decrementAndGet();
        incomingMessages.mark();

        final Message msg = event.getMessage();
        LOG.debug("Processing message <{}> from OutputBuffer.", msg.getId());

        final Set<MessageOutput> messageOutputs = outputRouter.getOutputsForMessage(msg);
        final CountDownLatch doneSignal = new CountDownLatch(messageOutputs.size());
        for (final MessageOutput output : messageOutputs) {
            if (output == null) {
                LOG.error("Got null output!");
                continue;
            }
            if (!output.isRunning()) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Skipping stopped output {}", output.getClass().getName());
                }
                continue;
            }
            try {
                LOG.debug("Writing message to [{}].", output.getName());
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Message id for [{}]: <{}>", output.getName(), msg.getId());
                }
                executor.submit(new Runnable() {
                    @Override
                    public void run() {
                        try (Timer.Context context = processTime.time()) {
                            output.write(msg);
                        } catch (Exception e) {
                            LOG.error("Error in output [" + output.getName() + "].", e);
                        } finally {
                            doneSignal.countDown();
                        }
                    }
                });

            } catch (Exception e) {
                LOG.error("Could not write message batch to output [" + output.getName() + "].", e);
                doneSignal.countDown();
            }
        }

        // Wait until all writer threads have finished or timeout is reached.
        if (!doneSignal.await(configuration.getOutputModuleTimeout(), TimeUnit.MILLISECONDS)) {
            LOG.warn("Timeout reached. Not waiting any longer for writer threads to complete.");
        }

        if (serverStatus.hasCapability(ServerStatus.Capability.STATSMODE)) {
            throughputStats.getBenchmarkCounter().increment();
        }

        throughputStats.getThroughputCounter().increment();

        LOG.debug("Wrote message <{}> to all outputs. Finished handling.", msg.getId());
    }
View Full Code Here

    @BeforeMethod
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        message = new Message("hello", "localhost", Tools.iso8601());

        when(kieSession.insert(message)).thenReturn(factHandle);
        when(kieSession.fireAllRules()).thenReturn(rulesFired);

        session = new DroolsRulesSession(kieSession);
View Full Code Here

    @Test
    public void runWithoutRules() {
        final DroolsEngine engine = new DroolsEngine(Sets.<URL>newHashSet());

        final int rulesFired = engine.evaluateInSharedSession(new Message("test message", "test", Tools.iso8601()));

        assertEquals(rulesFired, 0, "No rules should have fired");

        engine.stop();
    }
View Full Code Here

        assertTrue(valid1, "Rule should compile without errors");

        final boolean valid2 = engine.addRule(rule2);
        assertTrue(valid2, "Rule should compile without errors");

        final Message msg = new Message("test message", "test source", Tools.iso8601());
        final int fired = engine.evaluateInSharedSession(msg);

        assertTrue(msg.getFilterOut(), "msg is filtered out");
        assertEquals(fired, 2, "both rules should have fired");

        engine.stop();
    }
View Full Code Here

        assertFalse(deployed, "Should not deploy invalid rule");

        deployed = engine.addRule(validRule);
        assertTrue(deployed, "Subsequent deployment of valid rule works");

        engine.evaluateInSharedSession(new Message("foo", "source", Tools.iso8601()));

        engine.stop();
    }
View Full Code Here

* @author Lennart Koopmann <lennart@torch.sh>
*/
public class SubstringExtractorTest extends AbstractExtractorTest {
    @Test
    public void testBasicExtraction() throws Exception {
        Message msg = new Message("The short message", "TestUnit", Tools.iso8601());

        msg.addField("somefield", "<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001");

        SubstringExtractor x = new SubstringExtractor(metricRegistry, "foo", "foo", 0, Extractor.CursorStrategy.COPY, "somefield", "our_result", config(17, 30), "foo", noConverters(), Extractor.ConditionType.NONE, null);
        x.runExtractor(msg);

        assertNotNull(msg.getField("our_result"));
        assertEquals("<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001", msg.getField("somefield"));
        assertEquals("somesubsystem", msg.getField("our_result"));
    }
View Full Code Here

        assertEquals("somesubsystem", msg.getField("our_result"));
    }

    @Test
    public void testBasicExtractionWithCutStrategy() throws Exception {
        Message msg = new Message("The short message", "TestUnit", Tools.iso8601());

        msg.addField("somefield", "<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001");

        SubstringExtractor x = new SubstringExtractor(metricRegistry, "foo", "foo", 0, Extractor.CursorStrategy.CUT, "somefield", "our_result", config(17, 30), "foo", noConverters(), Extractor.ConditionType.NONE, null);
        x.runExtractor(msg);

        assertNotNull(msg.getField("our_result"));
        assertEquals("<10> 07 Aug 2013 : this is my message for username9001 id:9001", msg.getField("somefield"));
        assertEquals("somesubsystem", msg.getField("our_result"));
    }
View Full Code Here

    }

    private List<Message> buildMessages(final int count) {
        final ImmutableList.Builder<Message> builder = ImmutableList.builder();
        for (int i = 0; i < count; i++) {
            builder.add(new Message("message" + i, "test", Tools.iso8601()));
        }

        return builder.build();
    }
View Full Code Here

TOP

Related Classes of org.graylog2.plugin.Message

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.