Search in sources :

Example 1 with AbstractExecutionThreadService

use of com.google.common.util.concurrent.AbstractExecutionThreadService in project graylog2-server by Graylog2.

the class GeneratorTransport method doLaunch.

@Override
public void doLaunch(final MessageInput input) throws MisfireException {
    generatorService = new AbstractExecutionThreadService() {

        Thread runThread;

        @Override
        protected void run() throws Exception {
            while (isRunning()) {
                if (isThrottled()) {
                    blockUntilUnthrottled();
                }
                final RawMessage rawMessage = GeneratorTransport.this.produceRawMessage(input);
                if (rawMessage != null) {
                    input.processRawMessage(rawMessage);
                }
            }
        }

        @Override
        protected void startUp() throws Exception {
            runThread = Thread.currentThread();
        }

        @Override
        protected void triggerShutdown() {
            runThread.interrupt();
        }
    };
    generatorService.startAsync();
}
Also used : AbstractExecutionThreadService(com.google.common.util.concurrent.AbstractExecutionThreadService) RawMessage(org.graylog2.plugin.journal.RawMessage) MisfireException(org.graylog2.plugin.inputs.MisfireException)

Aggregations

AbstractExecutionThreadService (com.google.common.util.concurrent.AbstractExecutionThreadService)1 MisfireException (org.graylog2.plugin.inputs.MisfireException)1 RawMessage (org.graylog2.plugin.journal.RawMessage)1