Interface Connection<L>

    • Method Detail

      • getId

        long getId()
        Returns id of this instance, unique in the context of the JVM and the implementation class.
        Returns:
        id of this instance, never null.
      • isOpen

        boolean isOpen()
        Is Connection open and ready. Returns true, if connection is open and ready, or false otherwise.
        Specified by:
        isOpen in interface Closeable
        Returns:
        true, if connection is open and ready, or false otherwise.
      • assertOpen

        void assertOpen()
                 throws java.io.IOException
        Checks if this Connection is open and ready to be used. If this Connection is closed - this method throws IOException giving the reason why this Connection was closed.
        Specified by:
        assertOpen in interface Closeable
        Throws:
        java.io.IOException - giving the reason why this Closeable was closed.
      • getCloseReason

        CloseReason getCloseReason()
        Returns CloseReason if this Connection has been closed, or null otherwise.
        Returns:
        CloseReason if this Connection has been closed, or null otherwise
      • configureBlocking

        void configureBlocking​(boolean isBlocking)
        Sets the Connection mode.
        Parameters:
        isBlocking - the Connection mode. true, if Connection should operate in blocking mode, or false otherwise.
      • isBlocking

        boolean isBlocking()
        Returns:
        the Connection mode. true, if Connection is operating in blocking mode, or false otherwise.
      • configureStandalone

        @Deprecated
        void configureStandalone​(boolean isStandalone)
        Deprecated.
      • isStandalone

        @Deprecated
        boolean isStandalone()
        Deprecated.
      • obtainProcessorState

        <E> E obtainProcessorState​(Processor processor,
                                   java.util.function.Supplier<E> factory)
        Returns the Processor state associated with this Connection.
        Type Parameters:
        E - state of the Processor
        Parameters:
        processor - Processor
        factory - factory that is used to initialise the state
        Returns:
        the Processor state associated with this Connection.
      • executeInEventThread

        void executeInEventThread​(IOEvent event,
                                  java.lang.Runnable runnable)
        Executes the Runnable in the thread, responsible for running the given type of event on this Connection. The thread will be chosen based on Transport settings, especially current I/O strategy.
        Parameters:
        event - event to get the thread pool from
        runnable - Runnable to run in the thread
      • getPeerAddress

        L getPeerAddress()
        Get the connection peer address
        Returns:
        the connection peer address
      • getLocalAddress

        L getLocalAddress()
        Get the connection local address
        Returns:
        the connection local address
      • getReadBufferSize

        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

        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

        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

        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.
      • getMaxAsyncWriteQueueSize

        int getMaxAsyncWriteQueueSize()
        Get the max size (in bytes) of asynchronous write queue associated with connection.
        Returns:
        the max size (in bytes) of asynchronous write queue associated with connection.
        Since:
        2.2
      • setMaxAsyncWriteQueueSize

        void setMaxAsyncWriteQueueSize​(int maxAsyncWriteQueueSize)
        Set the max size (in bytes) of asynchronous write queue associated with connection.
        Parameters:
        maxAsyncWriteQueueSize - the max size (in bytes) of asynchronous write queue associated with connection.
        Since:
        2.2
      • getReadTimeout

        long getReadTimeout​(java.util.concurrent.TimeUnit timeUnit)
        Returns the current value for the blocking read timeout converted to the provided TimeUnit specification. If this value hasn't been explicitly set, it will default to 30 seconds.
        Parameters:
        timeUnit - the TimeUnit to convert the returned result to.
        Returns:
        the read timeout value
        Since:
        2.3
      • setReadTimeout

        void setReadTimeout​(long timeout,
                            java.util.concurrent.TimeUnit timeUnit)
        Specifies the timeout for the blocking reads. This may be overridden on a per-connection basis. A value of zero or less effectively disables the timeout.
        Parameters:
        timeout - the new timeout value
        timeUnit - the TimeUnit specification of the provided value.
        Since:
        2.3
        See Also:
        setReadTimeout(long, java.util.concurrent.TimeUnit)
      • getWriteTimeout

        long getWriteTimeout​(java.util.concurrent.TimeUnit timeUnit)
        Returns the current value for the blocking write timeout converted to the provided TimeUnit specification. If this value hasn't been explicitly set, it will default to 30 seconds.
        Parameters:
        timeUnit - the TimeUnit to convert the returned result to.
        Returns:
        the write timeout value
        Since:
        2.3
      • setWriteTimeout

        void setWriteTimeout​(long timeout,
                             java.util.concurrent.TimeUnit timeUnit)
        Specifies the timeout for the blocking writes. This may be overridden on a per-connection basis. A value of zero or less effectively disables the timeout.
        Parameters:
        timeout - the new timeout value
        timeUnit - the TimeUnit specification of the provided value.
        Since:
        2.3
        See Also:
        setWriteTimeout(long, java.util.concurrent.TimeUnit)
      • simulateIOEvent

        void simulateIOEvent​(IOEvent ioEvent)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • enableIOEvent

        void enableIOEvent​(IOEvent ioEvent)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • disableIOEvent

        void disableIOEvent​(IOEvent ioEvent)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • terminateSilently

        void terminateSilently()
        Close the Connection silently, no notification required on completion or failure.
        Specified by:
        terminateSilently in interface Closeable
      • terminateWithReason

        void terminateWithReason​(java.io.IOException reason)
        Closes the Connection and provides the reason description. This method is similar to terminateSilently(), but additionally provides the reason why the Connection will be closed.
        Specified by:
        terminateWithReason in interface Closeable
        Parameters:
        reason - reason why terminated. This will be thrown is Closeable.isOpen() is called subsequently
      • close

        GrizzlyFuture<Closeable> close()
        Gracefully close the Connection
        Specified by:
        close in interface Closeable
        Returns:
        Future, which could be checked in case, if close operation will be run asynchronously
        See Also:
        which is not asynchronous
      • closeSilently

        void closeSilently()
        Gracefully close the Connection silently, no notification required on completion or failure.
        Specified by:
        closeSilently in interface Closeable
      • closeWithReason

        void closeWithReason​(java.io.IOException reason)
        Gracefully closes the Connection and provides the reason description. This method is similar to closeSilently(), but additionally provides the reason why the Connection will be closed.
        Specified by:
        closeWithReason in interface Closeable
        Parameters:
        reason - reason why closed, this will be thrown by Closeable.isOpen() if called subsequently
      • notifyConnectionError

        void notifyConnectionError​(java.lang.Throwable error)
        Method gets invoked, when error occur during the Connection lifecycle.
        Parameters:
        error - Throwable.