public abstract class AbstractGelfTransport extends Object implements GelfTransport
GelfTransport implementation serving as parent for the concrete implementations.
This class is thread-safe.
| Modifier and Type | Field and Description |
|---|---|
protected GelfConfiguration |
config |
protected BlockingQueue<GelfMessage> |
queue |
| Constructor and Description |
|---|
AbstractGelfTransport(GelfConfiguration config)
Creates a new GELF transport with the given configuration.
|
AbstractGelfTransport(GelfConfiguration config,
BlockingQueue<GelfMessage> queue)
Creates a new GELF transport with the given configuration and
BlockingQueue. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
createBootstrap(io.netty.channel.EventLoopGroup workerGroup) |
void |
flushAndStopSynchronously(int waitDuration,
TimeUnit timeUnit,
int retries)
Blocks and stops the transport after flushing/sending all enqueued messages.
|
protected void |
scheduleReconnect(io.netty.channel.EventLoopGroup workerGroup) |
void |
send(GelfMessage message)
Sends the given message to the remote host.
|
void |
stop()
Stops the transport.
|
boolean |
trySend(GelfMessage message)
Tries to send the given message to the remote host.
|
protected final GelfConfiguration config
protected final BlockingQueue<GelfMessage> queue
public AbstractGelfTransport(GelfConfiguration config, BlockingQueue<GelfMessage> queue)
BlockingQueue.config - the client configurationqueue - the BlockingQueue used to buffer GELF messagespublic AbstractGelfTransport(GelfConfiguration config)
config - the client configurationprotected abstract void createBootstrap(io.netty.channel.EventLoopGroup workerGroup)
protected void scheduleReconnect(io.netty.channel.EventLoopGroup workerGroup)
public void send(GelfMessage message) throws InterruptedException
This implementation is backed by a BlockingQueue. When this method returns the
message has been added to the BlockingQueue but has not been sent to the remote
host yet.
send in interface GelfTransportmessage - message to send to the remote hostInterruptedExceptionpublic boolean trySend(GelfMessage message)
This implementation is backed by a BlockingQueue. When this method returns the
message has been added to the BlockingQueue but has not been sent to the remote
host yet.
trySend in interface GelfTransportmessage - message to send to the remote hostpublic void stop()
stop in interface GelfTransportpublic void flushAndStopSynchronously(int waitDuration,
TimeUnit timeUnit,
int retries)
waitDuration, timeUnit
and retries have elapsed.
Each retry waits for the indicated waitDuration and timeUnit again.
This can be used to gracefully shutdown the backend.flushAndStopSynchronously in interface GelfTransportwaitDuration - the wait duration.timeUnit - the time unit for the waitDuration.retries - the number of times to retry and wait for messages to flush. Zero retries indicates that
one initial attempt will be made.Copyright © 2014–2021 Graylog, Inc.. All rights reserved.