public class TcpSocketManager extends AbstractSocketManager
Modifier and Type | Class and Description |
---|---|
private static class |
TcpSocketManager.FactoryData
Data for the factory.
|
private class |
TcpSocketManager.Reconnector
Handles reconnecting to a Thread.
|
protected static class |
TcpSocketManager.TcpSocketManagerFactory
Factory to create a TcpSocketManager.
|
Modifier and Type | Field and Description |
---|---|
private int |
connectTimeoutMillis |
private static int |
DEFAULT_PORT
The default port number of remote logging server (4560).
|
static int |
DEFAULT_RECONNECTION_DELAY_MILLIS
The default reconnection delay (30000 milliseconds or 30 seconds).
|
private static TcpSocketManager.TcpSocketManagerFactory |
FACTORY |
private boolean |
immediateFail |
private int |
reconnectionDelay |
private TcpSocketManager.Reconnector |
reconnector |
private boolean |
retry |
private java.net.Socket |
socket |
private SocketOptions |
socketOptions |
host, inetAddress, port
byteBuffer, layout
count, LOGGER
Constructor and Description |
---|
TcpSocketManager(java.lang.String name,
java.io.OutputStream os,
java.net.Socket socket,
java.net.InetAddress inetAddress,
java.lang.String host,
int port,
int connectTimeoutMillis,
int delay,
boolean immediateFail,
Layout<? extends java.io.Serializable> layout,
int bufferSize)
|
TcpSocketManager(java.lang.String name,
java.io.OutputStream os,
java.net.Socket socket,
java.net.InetAddress inetAddress,
java.lang.String host,
int port,
int connectTimeoutMillis,
int delay,
boolean immediateFail,
Layout<? extends java.io.Serializable> layout,
int bufferSize,
SocketOptions socketOptions)
Constructs.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
closeOutputStream() |
private TcpSocketManager.Reconnector |
createReconnector() |
protected java.net.Socket |
createSocket(java.net.InetAddress host,
int port) |
protected java.net.Socket |
createSocket(java.lang.String host,
int port) |
int |
getConnectTimeoutMillis() |
java.util.Map<java.lang.String,java.lang.String> |
getContentFormat()
Gets this TcpSocketManager's content format.
|
java.net.Socket |
getSocket()
USE AT YOUR OWN RISK, method is public for testing purpose only for now.
|
static TcpSocketManager |
getSocketManager(java.lang.String host,
int port,
int connectTimeoutMillis,
int reconnectDelayMillis,
boolean immediateFail,
Layout<? extends java.io.Serializable> layout,
int bufferSize)
|
static TcpSocketManager |
getSocketManager(java.lang.String host,
int port,
int connectTimeoutMillis,
int reconnectDelayMillis,
boolean immediateFail,
Layout<? extends java.io.Serializable> layout,
int bufferSize,
SocketOptions socketOptions)
Obtains a TcpSocketManager.
|
SocketOptions |
getSocketOptions()
USE AT YOUR OWN RISK, method is public for testing purpose only for now.
|
protected void |
write(byte[] bytes,
int offset,
int length,
boolean immediateFlush)
Some output streams synchronize writes while others do not.
|
createOutputStream, drain, flush, flushBuffer, flushDestination, getByteBuffer, getManager, getOutputStream, hasOutputStream, isOpen, releaseSub, setOutputStream, skipFooter, write, write, write, writeFooter, writeToDestination
close, getCount, getLoggerContext, getName, hasManager, log, logDebug, logError, logWarn, release, stop, updateData
public static final int DEFAULT_RECONNECTION_DELAY_MILLIS
private static final int DEFAULT_PORT
private static final TcpSocketManager.TcpSocketManagerFactory FACTORY
private final int reconnectionDelay
private TcpSocketManager.Reconnector reconnector
private java.net.Socket socket
private final SocketOptions socketOptions
private final boolean retry
private final boolean immediateFail
private final int connectTimeoutMillis
@Deprecated public TcpSocketManager(java.lang.String name, java.io.OutputStream os, java.net.Socket socket, java.net.InetAddress inetAddress, java.lang.String host, int port, int connectTimeoutMillis, int delay, boolean immediateFail, Layout<? extends java.io.Serializable> layout, int bufferSize)
TcpSocketManager(String, OutputStream, Socket, InetAddress, String, int, int, int, boolean, Layout, int, SocketOptions)
.name
- The unique name of this connection.os
- The OutputStream.socket
- The Socket.inetAddress
- The Internet address of the host.host
- The name of the host.port
- The port number on the host.connectTimeoutMillis
- the connect timeout in milliseconds.delay
- Reconnection interval.immediateFail
- True if the write should fail if no socket is immediately available.layout
- The Layout.bufferSize
- The buffer size.public TcpSocketManager(java.lang.String name, java.io.OutputStream os, java.net.Socket socket, java.net.InetAddress inetAddress, java.lang.String host, int port, int connectTimeoutMillis, int delay, boolean immediateFail, Layout<? extends java.io.Serializable> layout, int bufferSize, SocketOptions socketOptions)
name
- The unique name of this connection.os
- The OutputStream.socket
- The Socket.inetAddress
- The Internet address of the host.host
- The name of the host.port
- The port number on the host.connectTimeoutMillis
- the connect timeout in milliseconds.delay
- Reconnection interval.immediateFail
- True if the write should fail if no socket is immediately available.layout
- The Layout.bufferSize
- The buffer size.@Deprecated public static TcpSocketManager getSocketManager(java.lang.String host, int port, int connectTimeoutMillis, int reconnectDelayMillis, boolean immediateFail, Layout<? extends java.io.Serializable> layout, int bufferSize)
host
- The host to connect to.port
- The port on the host.connectTimeoutMillis
- the connect timeout in millisecondsreconnectDelayMillis
- The interval to pause between retries.bufferSize
- The buffer size.public static TcpSocketManager getSocketManager(java.lang.String host, int port, int connectTimeoutMillis, int reconnectDelayMillis, boolean immediateFail, Layout<? extends java.io.Serializable> layout, int bufferSize, SocketOptions socketOptions)
host
- The host to connect to.port
- The port on the host.connectTimeoutMillis
- the connect timeout in millisecondsreconnectDelayMillis
- The interval to pause between retries.bufferSize
- The buffer size.protected void write(byte[] bytes, int offset, int length, boolean immediateFlush)
OutputStreamManager
write
in class OutputStreamManager
bytes
- The serialized Log event.offset
- The offset into the byte array.length
- The number of bytes to write.immediateFlush
- flushes immediately after writing.protected boolean closeOutputStream()
closeOutputStream
in class OutputStreamManager
public int getConnectTimeoutMillis()
public java.util.Map<java.lang.String,java.lang.String> getContentFormat()
getContentFormat
in class AbstractSocketManager
private TcpSocketManager.Reconnector createReconnector()
protected java.net.Socket createSocket(java.net.InetAddress host, int port) throws java.io.IOException
java.io.IOException
protected java.net.Socket createSocket(java.lang.String host, int port) throws java.io.IOException
java.io.IOException
public SocketOptions getSocketOptions()
public java.net.Socket getSocket()