Class RemoteReceiverStreamClient
- All Implemented Interfaces:
Client,RemoteReceiverClient,ContextAware,Closeable,AutoCloseable,Runnable
RemoteReceiverClient that writes serialized logging events to an
OutputStream.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final OutputStreamprivate BlockingQueue<Serializable> private final SocketFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
ConstructorsConstructorDescriptionRemoteReceiverStreamClient(String id, OutputStream outputStream) Constructs a new client.RemoteReceiverStreamClient(String id, Socket socket) Constructs a new client. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes any resources that are held by the client.private ObjectOutputStreambooleanoffer(Serializable event) Offers an event to the client.voidrun()voidsetQueue(BlockingQueue<Serializable> queue) Sets the client's event queue.Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Field Details
-
clientId
-
socket
-
outputStream
-
queue
-
-
Constructor Details
-
RemoteReceiverStreamClient
Constructs a new client.- Parameters:
id- identifier string for the clientsocket- socket to which logging events will be written
-
RemoteReceiverStreamClient
RemoteReceiverStreamClient(String id, OutputStream outputStream) Constructs a new client.This constructor exists primarily to support unit tests where it is inconvenient to have to create a socket for the test.
- Parameters:
id- identifier string for the clientoutputStream- output stream to which logging Events will be written
-
-
Method Details
-
setQueue
Sets the client's event queue.This method must be invoked before the
Runnable.run()method is invoked.- Specified by:
setQueuein interfaceRemoteReceiverClient- Parameters:
queue- the queue to set
-
offer
Offers an event to the client.- Specified by:
offerin interfaceRemoteReceiverClient- Parameters:
event- the subject event- Returns:
trueif the client's queue accepted the event,falseif the client's queue is full
-
close
public void close()Closes any resources that are held by the client.Note that (as described in Doug Lea's discussion about interrupting I/O operations in "Concurrent Programming in Java" (Addison-Wesley Professional, 2nd edition, 1999) this method is used to interrupt any blocked I/O operation in the client when the server is shutting down. The client implementation must anticipate this potential, and gracefully exit when the blocked I/O operation throws the relevant
IOExceptionsubclass.Note also, that unlike
Closeable.close()this method is not permitted to propagate anyIOExceptionthat occurs when closing the underlying resource(s). -
run
public void run() -
createObjectOutputStream
- Throws:
IOException
-