Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assign messages to the default stream (#3098)
* add default stream to each message when entering the processing engine Unify legacy ProcessBufferProcessor class with its sole subclass turn its provider into a factory to save mutable state create singleton provider for default stream * prevent updates (create, edit, delete) to default stream or its stream rules the default stream it doesn't have rules and the UI will not show the actions necessary to modify it, this prevents using the API to mutate it * the default stream doesn't have stream rules, don't check the service in tests * Remove obsolete DefaultStreamCreated marker
- Loading branch information
Showing
10 changed files
with
203 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
graylog2-server/src/main/java/org/graylog2/bindings/providers/DefaultStreamProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,71 @@ | |||
/** | |||
* This file is part of Graylog. | |||
* | |||
* Graylog is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* Graylog is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with Graylog. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.graylog2.bindings.providers; | |||
|
|||
import org.graylog2.database.NotFoundException; | |||
import org.graylog2.gelfclient.util.Uninterruptibles; | |||
import org.graylog2.plugin.streams.Stream; | |||
import org.graylog2.streams.StreamService; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
|
|||
import java.util.concurrent.TimeUnit; | |||
import java.util.concurrent.atomic.AtomicReference; | |||
|
|||
import javax.inject.Inject; | |||
import javax.inject.Provider; | |||
import javax.inject.Singleton; | |||
|
|||
@Singleton | |||
public class DefaultStreamProvider implements Provider<Stream> { | |||
private static final Logger LOG = LoggerFactory.getLogger(DefaultStreamProvider.class); | |||
|
|||
private final StreamService service; | |||
|
|||
private AtomicReference<Stream> sharedInstance = new AtomicReference<>(); | |||
|
|||
@Inject | |||
private DefaultStreamProvider(StreamService service) { | |||
this.service = service; | |||
} | |||
|
|||
@Override | |||
public Stream get() { | |||
Stream defaultStream = sharedInstance.get(); | |||
if (defaultStream != null) { | |||
return defaultStream; | |||
} | |||
|
|||
synchronized (this) { | |||
defaultStream = sharedInstance.get(); | |||
if (defaultStream != null) { | |||
return defaultStream; | |||
} | |||
do { | |||
try { | |||
LOG.debug("Loading shared default stream instance"); | |||
defaultStream = service.load(Stream.DEFAULT_STREAM_ID); | |||
} catch (NotFoundException ignored) { | |||
LOG.warn("Unable to load default stream, retrying. Processing is blocked until this succeeds."); | |||
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS); | |||
} | |||
} while (defaultStream == null); | |||
sharedInstance.set(defaultStream); | |||
} | |||
return defaultStream; | |||
} | |||
} |
64 changes: 0 additions & 64 deletions
64
...g2-server/src/main/java/org/graylog2/buffers/processors/ServerProcessBufferProcessor.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.