public class TcpSocketManager extends AbstractSocketManager
Modifier and Type | Class and Description |
---|---|
protected static class |
TcpSocketManager.TcpSocketManagerFactory<M extends TcpSocketManager,T extends org.apache.logging.log4j.core.net.TcpSocketManager.FactoryData>
Factory to create a TcpSocketManager.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_RECONNECTION_DELAY_MILLIS
The default reconnection delay (30000 milliseconds or 30 seconds).
|
host, inetAddress, port
byteBuffer, layout
count, LOGGER
Constructor and Description |
---|
TcpSocketManager(String name,
OutputStream os,
Socket socket,
InetAddress inetAddress,
String host,
int port,
int connectTimeoutMillis,
int reconnectionDelayMillis,
boolean immediateFail,
Layout<? extends Serializable> layout,
int bufferSize)
|
TcpSocketManager(String name,
OutputStream os,
Socket socket,
InetAddress inetAddress,
String host,
int port,
int connectTimeoutMillis,
int reconnectionDelayMillis,
boolean immediateFail,
Layout<? extends Serializable> layout,
int bufferSize,
SocketOptions socketOptions)
Constructs.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
closeOutputStream() |
protected Socket |
createSocket(String host,
int port) |
protected static Socket |
createSocket(String host,
int port,
SocketOptions socketOptions,
int connectTimeoutMillis) |
int |
getConnectTimeoutMillis() |
Map<String,String> |
getContentFormat()
Gets this TcpSocketManager's content format.
|
int |
getReconnectionDelayMillis() |
Socket |
getSocket()
USE AT YOUR OWN RISK, method is public for testing purpose only for now.
|
static TcpSocketManager |
getSocketManager(String host,
int port,
int connectTimeoutMillis,
int reconnectDelayMillis,
boolean immediateFail,
Layout<? extends Serializable> layout,
int bufferSize)
|
static TcpSocketManager |
getSocketManager(String host,
int port,
int connectTimeoutMillis,
int reconnectDelayMillis,
boolean immediateFail,
Layout<? extends 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.
|
String |
toString() |
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, writeBytes, writeBytes, writeFooter, writeToDestination
close, getCount, getLoggerContext, getName, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop, updateData
public static final int DEFAULT_RECONNECTION_DELAY_MILLIS
@Deprecated public TcpSocketManager(String name, OutputStream os, Socket socket, InetAddress inetAddress, String host, int port, int connectTimeoutMillis, int reconnectionDelayMillis, boolean immediateFail, Layout<? extends 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.reconnectionDelayMillis
- Reconnection interval.immediateFail
- True if the write should fail if no socket is immediately available.layout
- The Layout.bufferSize
- The buffer size.public TcpSocketManager(String name, OutputStream os, Socket socket, InetAddress inetAddress, String host, int port, int connectTimeoutMillis, int reconnectionDelayMillis, boolean immediateFail, Layout<? extends 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.reconnectionDelayMillis
- 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(String host, int port, int connectTimeoutMillis, int reconnectDelayMillis, boolean immediateFail, Layout<? extends 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(String host, int port, int connectTimeoutMillis, int reconnectDelayMillis, boolean immediateFail, Layout<? extends 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 Map<String,String> getContentFormat()
getContentFormat
in class AbstractSocketManager
protected Socket createSocket(String host, int port) throws IOException
IOException
protected static Socket createSocket(String host, int port, SocketOptions socketOptions, int connectTimeoutMillis) throws IOException
IOException
public SocketOptions getSocketOptions()
public Socket getSocket()
public int getReconnectionDelayMillis()
Copyright © 1999-2019 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.