Class RemoteReceiverStreamClient

    • Field Detail

      • clientId

        private final java.lang.String clientId
      • socket

        private final java.net.Socket socket
      • outputStream

        private final java.io.OutputStream outputStream
      • queue

        private java.util.concurrent.BlockingQueue<java.io.Serializable> queue
    • Constructor Detail

      • RemoteReceiverStreamClient

        public RemoteReceiverStreamClient​(java.lang.String id,
                                          java.net.Socket socket)
        Constructs a new client.
        Parameters:
        id - identifier string for the client
        socket - socket to which logging events will be written
      • RemoteReceiverStreamClient

        RemoteReceiverStreamClient​(java.lang.String id,
                                   java.io.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 client
        outputStream - output stream to which logging Events will be written
    • Method Detail

      • setQueue

        public void setQueue​(java.util.concurrent.BlockingQueue<java.io.Serializable> queue)
        Sets the client's event queue.

        This method must be invoked before the Runnable.run() method is invoked.

        Specified by:
        setQueue in interface RemoteReceiverClient
        Parameters:
        queue - the queue to set
      • offer

        public boolean offer​(java.io.Serializable event)
        Offers an event to the client.
        Specified by:
        offer in interface RemoteReceiverClient
        Parameters:
        event - the subject event
        Returns:
        true if the client's queue accepted the event, false if 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 IOException subclass.

        Note also, that unlike Closeable.close() this method is not permitted to propagate any IOException that occurs when closing the underlying resource(s).

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface Client
        Specified by:
        close in interface java.io.Closeable
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • createObjectOutputStream

        private java.io.ObjectOutputStream createObjectOutputStream()
                                                             throws java.io.IOException
        Throws:
        java.io.IOException