Package io.dropwizard.logging.common
Class ResilientSocketOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- io.dropwizard.logging.common.ResilientSocketOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class ResilientSocketOutputStream extends OutputStream
Represents a resilient persistent connection via TCP as anOutputStream
. Automatically tries to reconnect to the server if it encounters errors during writing data via a TCP connection.
-
-
Field Summary
Fields Modifier and Type Field Description protected OutputStream
os
-
Constructor Summary
Constructors Constructor Description ResilientSocketOutputStream(String host, int port, int connectionTimeoutMs, int sendBufferSize, SocketFactory socketFactory)
Creates a new stream based on the socket configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
ch.qos.logback.core.Context
getContext()
void
setContext(ch.qos.logback.core.Context context)
void
write(byte[] b, int off, int len)
void
write(int b)
-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Field Detail
-
os
protected OutputStream os
-
-
Constructor Detail
-
ResilientSocketOutputStream
public ResilientSocketOutputStream(String host, int port, int connectionTimeoutMs, int sendBufferSize, SocketFactory socketFactory)
Creates a new stream based on the socket configuration.- Parameters:
host
- The host or an IP address of the server.port
- The port on the server which accepts TCP connections.connectionTimeoutMs
- The timeout for establishing a new TCP connection.sendBufferSize
- The size of the send buffer of the socket stream in bytes.socketFactory
- The factory for customizing the client socket.
-
-
Method Detail
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len)
- Overrides:
write
in classOutputStream
-
write
public void write(int b)
- Specified by:
write
in classOutputStream
-
flush
public void flush()
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
-
getContext
public ch.qos.logback.core.Context getContext()
-
setContext
public void setContext(ch.qos.logback.core.Context context)
-
-