Package io.dropwizard.logging.common
Class ResilientSocketOutputStream
java.lang.Object
java.io.OutputStream
io.dropwizard.logging.common.ResilientSocketOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Represents a resilient persistent connection via TCP as an
OutputStream.
Automatically tries to reconnect to the server if it encounters errors during writing
data via a TCP connection.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionResilientSocketOutputStream(String host, int port, int connectionTimeoutMs, int sendBufferSize, SocketFactory socketFactory) Creates a new stream based on the socket configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()ch.qos.logback.core.ContextvoidsetContext(ch.qos.logback.core.Context context) voidwrite(byte[] b, int off, int len) voidwrite(int b) Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Field Details
-
os
-
-
Constructor Details
-
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 Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) - Overrides:
writein classOutputStream
-
write
public void write(int b) - Specified by:
writein classOutputStream
-
flush
public void flush()- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream
-
getContext
public ch.qos.logback.core.Context getContext() -
setContext
public void setContext(ch.qos.logback.core.Context context)
-