Class AbstractByteBufferCommandTransport

    • Constructor Detail

      • AbstractByteBufferCommandTransport

        public AbstractByteBufferCommandTransport()
    • Method Detail

      • write

        protected abstract void write​(ByteBuffer header,
                                      ByteBuffer data)
                               throws IOException
        Write the packet.
        Parameters:
        header - the header to write.
        data - the data to write.
        Throws:
        IOException - if the data could not be written.
      • setFrameSize

        public void setFrameSize​(int transportFrameSize)
        Set the frame size.
        Parameters:
        transportFrameSize - the new frame size (must be in the range 1-Short.MAX_VALUE).
      • getChannel

        @Nullable
        protected Channel getChannel()
        Gets the channel.
        Returns:
        the channel.
      • write

        public final void write​(Command cmd,
                                boolean last)
                         throws IOException
        Called by Channel to send one command to the other side. Channel serializes the invocation of this method for ordering. That is, at any given point in time only one thread executes this method.

        Asynchronous transport must serialize the given command object before returning from this method, as its content can be modified by the calling thread as soon as this method returns. Also, if an asynchronous transport chooses to return from this method without committing data to the network, then it is also responsible for a flow control (by blocking this method if too many commands are queueing up waiting for the network to unclog.)

        Specified by:
        write in class CommandTransport
        Parameters:
        cmd - The command object that needs to be sent. Never null. This must be serialized via Command.writeTo(Channel, ObjectOutputStream)
        last - Informational flag that indicates that this is the last call of the CommandTransport.write(Command, boolean).
        Throws:
        IOException
      • terminate

        public void terminate​(IOException e)
        Indicates that the endpoint has encountered a problem. This tells the transport that it shouldn't expect future invocation of receive(ByteBuffer), and it'll abort the communication.