Search in sources :

Example 6 with DefaultStream

use of org.graylog2.plugin.streams.DefaultStream in project graylog2-server by Graylog2.

the class DefaultStreamProvider method get.

@Override
public Stream get() {
    Stream defaultStream = sharedInstance.get();
    if (defaultStream != null) {
        return defaultStream;
    }
    synchronized (this) {
        defaultStream = sharedInstance.get();
        if (defaultStream != null) {
            return defaultStream;
        }
        int i = 0;
        do {
            try {
                LOG.debug("Loading shared default stream instance");
                defaultStream = service.load(Stream.DEFAULT_STREAM_ID);
            } catch (NotFoundException ignored) {
                if (i % 10 == 0) {
                    LOG.warn("Unable to load default stream, tried {} times, retrying every 500ms. Processing is blocked until this succeeds.", i + 1);
                }
                i++;
                Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
            }
        } while (defaultStream == null);
        sharedInstance.set(defaultStream);
    }
    return defaultStream;
}
Also used : NotFoundException(org.graylog2.database.NotFoundException) Stream(org.graylog2.plugin.streams.Stream)

Example 7 with DefaultStream

use of org.graylog2.plugin.streams.DefaultStream in project graylog2-server by Graylog2.

the class FunctionsSnippetsTest method removeFromStream.

@Test
public void removeFromStream() {
    final Rule rule = parser.parseRule(ruleForTest(), true);
    final Message message = evaluateRule(rule, msg -> msg.addStream(otherStream));
    assertThat(message).isNotNull();
    assertThat(message.getStreams()).containsOnly(defaultStream);
}
Also used : CreateMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage) CloneMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage) DropMessage(org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage) Message(org.graylog2.plugin.Message) MockitoRule(org.mockito.junit.MockitoRule) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Example 8 with DefaultStream

use of org.graylog2.plugin.streams.DefaultStream in project graylog2-server by Graylog2.

the class FunctionsSnippetsTest method removeFromStreamRetainDefault.

@Test
public void removeFromStreamRetainDefault() {
    final Rule rule = parser.parseRule(ruleForTest(), true);
    final Message message = evaluateRule(rule, msg -> msg.addStream(otherStream));
    assertThat(message).isNotNull();
    assertThat(message.getStreams()).containsOnly(defaultStream);
}
Also used : CreateMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage) CloneMessage(org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage) DropMessage(org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage) Message(org.graylog2.plugin.Message) MockitoRule(org.mockito.junit.MockitoRule) Rule(org.graylog.plugins.pipelineprocessor.ast.Rule) BaseParserTest(org.graylog.plugins.pipelineprocessor.BaseParserTest) Test(org.junit.Test)

Aggregations

Message (org.graylog2.plugin.Message)4 Stream (org.graylog2.plugin.streams.Stream)4 Test (org.junit.Test)3 BaseParserTest (org.graylog.plugins.pipelineprocessor.BaseParserTest)2 Rule (org.graylog.plugins.pipelineprocessor.ast.Rule)2 CloneMessage (org.graylog.plugins.pipelineprocessor.functions.messages.CloneMessage)2 CreateMessage (org.graylog.plugins.pipelineprocessor.functions.messages.CreateMessage)2 DropMessage (org.graylog.plugins.pipelineprocessor.functions.messages.DropMessage)2 MockitoRule (org.mockito.junit.MockitoRule)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 EventBus (com.google.common.eventbus.EventBus)1 Nullable (javax.annotation.Nullable)1 ObjectId (org.bson.types.ObjectId)1 Function (org.graylog.plugins.pipelineprocessor.ast.functions.Function)1 BooleanConversion (org.graylog.plugins.pipelineprocessor.functions.conversion.BooleanConversion)1 DoubleConversion (org.graylog.plugins.pipelineprocessor.functions.conversion.DoubleConversion)1 IsBoolean (org.graylog.plugins.pipelineprocessor.functions.conversion.IsBoolean)1 IsCollection (org.graylog.plugins.pipelineprocessor.functions.conversion.IsCollection)1 IsDouble (org.graylog.plugins.pipelineprocessor.functions.conversion.IsDouble)1 IsList (org.graylog.plugins.pipelineprocessor.functions.conversion.IsList)1