public class GelfTCPSender extends AbstractNioSender<SocketChannel> implements GelfSender
| Modifier and Type | Field and Description |
|---|---|
static String |
CONNECTION_TIMEOUT |
static String |
KEEPALIVE |
static String |
MAX_WRITE_BACKOFF_TIME |
static String |
READ_TIMEOUT |
static String |
RETRIES |
static String |
WRITE_BACKOFF_THRESHOLD |
static String |
WRITE_BACKOFF_TIME |
INITIAL_BUFFER_SIZE, PROPERTY_BUFFER_SIZE| Constructor and Description |
|---|
GelfTCPSender(String host,
int port,
int connectTimeoutMs,
int readTimeoutMs,
ErrorReporter errorReporter) |
GelfTCPSender(String host,
int port,
int connectTimeoutMs,
int readTimeoutMs,
int deliveryAttempts,
boolean keepAlive,
biz.paluch.logging.gelf.intern.sender.BackOff backoff,
int writeBackoffThreshold,
ErrorReporter errorReporter) |
GelfTCPSender(String host,
int port,
int connectTimeoutMs,
int readTimeoutMs,
int deliveryAttempts,
boolean keepAlive,
ErrorReporter errorReporter) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
connect() |
protected SocketChannel |
createSocketChannel(int readTimeoutMs,
boolean keepAlive) |
protected boolean |
isConnected(SocketChannel channel) |
boolean |
sendMessage(GelfMessage message)
Send the Gelf message.
|
protected void |
write(ByteBuffer buffer) |
channel, close, getHost, getPort, isConnected, isShutdown, reportError, setChannelclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic static final String CONNECTION_TIMEOUT
public static final String READ_TIMEOUT
public static final String RETRIES
public static final String KEEPALIVE
public static final String WRITE_BACKOFF_TIME
public static final String WRITE_BACKOFF_THRESHOLD
public static final String MAX_WRITE_BACKOFF_TIME
public GelfTCPSender(String host, int port, int connectTimeoutMs, int readTimeoutMs, ErrorReporter errorReporter) throws IOException
host - the host, must not be null.port - the port.connectTimeoutMs - connection timeout, in TimeUnit.MILLISECONDS.readTimeoutMs - read timeout, in TimeUnit.MILLISECONDS.errorReporter - the error reporter, must not be null.IOException - in case of I/O errorspublic GelfTCPSender(String host, int port, int connectTimeoutMs, int readTimeoutMs, int deliveryAttempts, boolean keepAlive, ErrorReporter errorReporter) throws IOException
host - the host, must not be null.port - the port.connectTimeoutMs - connection timeout, in TimeUnit.MILLISECONDS.readTimeoutMs - read timeout, in TimeUnit.MILLISECONDS.deliveryAttempts - number of delivery attempts.keepAlive - true to enable TCP keep-alive.errorReporter - the error reporter, must not be null.IOException - in case of I/O errorspublic GelfTCPSender(String host, int port, int connectTimeoutMs, int readTimeoutMs, int deliveryAttempts, boolean keepAlive, biz.paluch.logging.gelf.intern.sender.BackOff backoff, int writeBackoffThreshold, ErrorReporter errorReporter) throws IOException
host - the host, must not be null.port - the port.connectTimeoutMs - connection timeout, in TimeUnit.MILLISECONDS.readTimeoutMs - read timeout, in TimeUnit.MILLISECONDS.deliveryAttempts - number of delivery attempts.keepAlive - true to enable TCP keep-alive.backoff - Backoff strategy to activate if a socket sender buffer is full and several attempts to write to the socket are unsuccessful due to it.writeBackoffThreshold - attempts to write to a socket before a backoff will be activated.errorReporter - the error reporter, must not be null.IOException - in case of I/O errorsprotected SocketChannel createSocketChannel(int readTimeoutMs, boolean keepAlive) throws IOException
IOExceptionpublic boolean sendMessage(GelfMessage message)
GelfSendersendMessage in interface GelfSendermessage - the messageprotected void write(ByteBuffer buffer) throws IOException, InterruptedException
IOExceptionInterruptedExceptionprotected boolean connect()
throws IOException
IOExceptionprotected boolean isConnected(SocketChannel channel)
isConnected in class AbstractNioSender<SocketChannel>Copyright © 2013–2023. All rights reserved.