Class TCPNIOConnection

java.lang.Object
org.glassfish.grizzly.nio.NIOConnection
org.glassfish.grizzly.nio.transport.TCPNIOConnection
All Implemented Interfaces:
AttributeStorage, Closeable, Connection<SocketAddress>, MonitoringAware<ConnectionProbe>, OutputSink, Readable<SocketAddress>, Writeable<SocketAddress>
Direct Known Subclasses:
TCPNIOServerConnection

public class TCPNIOConnection extends NIOConnection
Connection implementation for the TCPNIOTransport
Author:
Alexey Stashok
  • Constructor Details

  • Method Details

    • setSelectionKey

      protected void setSelectionKey(SelectionKey selectionKey)
      Overrides:
      setSelectionKey in class NIOConnection
    • setSelectorRunner

      protected void setSelectorRunner(SelectorRunner selectorRunner)
      Overrides:
      setSelectorRunner in class NIOConnection
    • preClose

      protected void preClose()
      Overrides:
      preClose in class NIOConnection
    • notifyReady

      protected boolean notifyReady()
    • getPeerAddress

      public SocketAddress getPeerAddress()
      Returns the address of the endpoint this Connection is connected to, or null if it is unconnected.
      Returns:
      the address of the endpoint this Connection is connected to, or null if it is unconnected.
    • getLocalAddress

      public SocketAddress getLocalAddress()
      Returns the local address of this Connection, or null if it is unconnected.
      Returns:
      the local address of this Connection, or null if it is unconnected.
    • resetProperties

      protected void resetProperties()
    • getReadBufferSize

      public int getReadBufferSize()
      Get the default size of Buffers, which will be allocated for reading data from Connection. The value less or equal to zero will be ignored.
      Returns:
      the default size of Buffers, which will be allocated for reading data from Connection.
    • setReadBufferSize

      public void setReadBufferSize(int readBufferSize)
      Set the default size of Buffers, which will be allocated for reading data from Connection. The value less or equal to zero will be ignored.
      Parameters:
      readBufferSize - the default size of Buffers, which will be allocated for reading data from Connection.
    • getWriteBufferSize

      public int getWriteBufferSize()
      Get the default size of Buffers, which will be allocated for writing data to Connection.
      Returns:
      the default size of Buffers, which will be allocated for writing data to Connection.
    • setWriteBufferSize

      public void setWriteBufferSize(int writeBufferSize)
      Set the default size of Buffers, which will be allocated for writing data to Connection.
      Parameters:
      writeBufferSize - the default size of Buffers, which will be allocated for writing data to Connection.
    • setConnectResultHandler

      protected final void setConnectResultHandler(TCPNIOConnection.ConnectResultHandler connectHandler)
    • onConnect

      protected final void onConnect() throws IOException
      Method will be called, when the connection gets connected.
      Throws:
      IOException
    • checkConnectFailed

      protected final void checkConnectFailed(Throwable failure)
      Method will be called in order to check if failure happened before Connection was reported as connected.
    • terminate0

      protected void terminate0(CompletionHandler<Closeable> completionHandler, CloseReason closeReason)
      Overrides:
      terminate0 in class NIOConnection
    • onRead

      protected final void onRead(Buffer data, int size)
      Method will be called, when some data was read on the connection
    • enableInitialOpRead

      protected void enableInitialOpRead() throws IOException
      Description copied from class: NIOConnection
      Enables OP_READ if it has never been enabled before.
      Overrides:
      enableInitialOpRead in class NIOConnection
      Throws:
      IOException
    • onWrite

      protected final void onWrite(Buffer data, long size)
      Method will be called, when some data was written on the connection
    • canWrite

      public boolean canWrite()
      Returns:
      true if a write to this OutputSink will succeed, otherwise returns false.
    • canWrite

      @Deprecated public boolean canWrite(int length)
      Deprecated.
      Parameters:
      length - specifies the number of bytes (or characters) that require writing
      Returns:
      true if a write to this OutputSink will succeed, otherwise returns false.
    • notifyCanWrite

      public void notifyCanWrite(WriteHandler writeHandler)
      Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write more bytes (or characters). Note that once the WriteHandler has been notified, it will not be considered for notification again at a later point in time.
      Parameters:
      writeHandler - the WriteHandler that should be notified when it's possible to write more data.
    • notifyCanWrite

      @Deprecated public void notifyCanWrite(WriteHandler handler, int length)
      Deprecated.
      Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write length bytes (or characters). Note that once the WriteHandler has been notified, it will not be considered for notification again at a later point in time.
      Parameters:
      handler - the WriteHandler that should be notified when it's possible to write length bytes.
      length - the number of bytes or characters that require writing.
    • toString

      public String toString()
      Overrides:
      toString in class Object