Class NettyIoSession

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.nio.channels.Channel, org.apache.sshd.common.Closeable, org.apache.sshd.common.io.IoSession, org.apache.sshd.common.util.net.ConnectionEndpointsIndicator

    public class NettyIoSession
    extends org.apache.sshd.common.util.closeable.AbstractCloseable
    implements org.apache.sshd.common.io.IoSession
    The Netty based IoSession implementation.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  NettyIoSession.Adapter
      Netty adapter to use as a bridge, with extra handling for suspending reads.
      protected static class  NettyIoSession.DefaultIoWriteFuture  
      • Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable

        org.apache.sshd.common.util.closeable.AbstractCloseable.State
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.net.SocketAddress acceptanceAddress  
      protected io.netty.channel.ChannelInboundHandlerAdapter adapter  
      protected java.util.Map<java.lang.Object,​java.lang.Object> attributes  
      protected io.netty.channel.ChannelHandlerContext context  
      protected org.apache.sshd.common.io.IoHandler handler  
      protected long id  
      protected io.netty.channel.ChannelFuture prev  
      protected java.util.concurrent.atomic.AtomicBoolean readSuspended  
      protected java.net.SocketAddress remoteAddr  
      protected NettyIoService service  
      • Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable

        closeFuture, futureLock, state
      • Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean

        log
    • Constructor Summary

      Constructors 
      Constructor Description
      NettyIoSession​(NettyIoService service, org.apache.sshd.common.io.IoHandler handler, java.net.SocketAddress acceptanceAddress)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void channelActive​(io.netty.channel.ChannelHandlerContext ctx)  
      protected void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)  
      protected void channelRead​(io.netty.channel.ChannelHandlerContext ctx, org.apache.sshd.common.util.Readable msg)  
      protected org.apache.sshd.common.future.CloseFuture doCloseGracefully()  
      protected void doCloseImmediately()  
      protected void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)  
      java.net.SocketAddress getAcceptanceAddress()  
      java.lang.Object getAttribute​(java.lang.Object key)  
      long getId()  
      java.net.SocketAddress getLocalAddress()  
      java.net.SocketAddress getRemoteAddress()  
      org.apache.sshd.common.io.IoService getService()  
      java.lang.Object removeAttribute​(java.lang.Object key)  
      void resumeRead()  
      java.lang.Object setAttribute​(java.lang.Object key, java.lang.Object value)  
      java.lang.Object setAttributeIfAbsent​(java.lang.Object key, java.lang.Object value)  
      void shutdownOutputStream()  
      void suspend()
      Intended for tests simulating a sudden connection drop only! Do not call otherwise.
      void suspendRead()  
      java.lang.String toString()  
      org.apache.sshd.common.io.IoWriteFuture writeBuffer​(org.apache.sshd.common.util.buffer.Buffer buffer)  
      • Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable

        addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, preClose, removeCloseFutureListener
      • Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean

        debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.apache.sshd.common.Closeable

        addCloseFutureListener, close, isClosed, isClosing, isOpen, removeCloseFutureListener
      • Methods inherited from interface org.apache.sshd.common.io.IoSession

        close
    • Field Detail

      • attributes

        protected final java.util.Map<java.lang.Object,​java.lang.Object> attributes
      • handler

        protected final org.apache.sshd.common.io.IoHandler handler
      • id

        protected final long id
      • context

        protected volatile io.netty.channel.ChannelHandlerContext context
      • remoteAddr

        protected java.net.SocketAddress remoteAddr
      • prev

        protected io.netty.channel.ChannelFuture prev
      • adapter

        protected final io.netty.channel.ChannelInboundHandlerAdapter adapter
      • readSuspended

        protected final java.util.concurrent.atomic.AtomicBoolean readSuspended
      • acceptanceAddress

        private final java.net.SocketAddress acceptanceAddress
    • Constructor Detail

      • NettyIoSession

        public NettyIoSession​(NettyIoService service,
                              org.apache.sshd.common.io.IoHandler handler,
                              java.net.SocketAddress acceptanceAddress)
    • Method Detail

      • getId

        public long getId()
        Specified by:
        getId in interface org.apache.sshd.common.io.IoSession
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.Object key)
        Specified by:
        getAttribute in interface org.apache.sshd.common.io.IoSession
      • setAttribute

        public java.lang.Object setAttribute​(java.lang.Object key,
                                             java.lang.Object value)
        Specified by:
        setAttribute in interface org.apache.sshd.common.io.IoSession
      • setAttributeIfAbsent

        public java.lang.Object setAttributeIfAbsent​(java.lang.Object key,
                                                     java.lang.Object value)
        Specified by:
        setAttributeIfAbsent in interface org.apache.sshd.common.io.IoSession
      • removeAttribute

        public java.lang.Object removeAttribute​(java.lang.Object key)
        Specified by:
        removeAttribute in interface org.apache.sshd.common.io.IoSession
      • getRemoteAddress

        public java.net.SocketAddress getRemoteAddress()
        Specified by:
        getRemoteAddress in interface org.apache.sshd.common.util.net.ConnectionEndpointsIndicator
      • getLocalAddress

        public java.net.SocketAddress getLocalAddress()
        Specified by:
        getLocalAddress in interface org.apache.sshd.common.util.net.ConnectionEndpointsIndicator
      • getAcceptanceAddress

        public java.net.SocketAddress getAcceptanceAddress()
        Specified by:
        getAcceptanceAddress in interface org.apache.sshd.common.io.IoSession
      • writeBuffer

        public org.apache.sshd.common.io.IoWriteFuture writeBuffer​(org.apache.sshd.common.util.buffer.Buffer buffer)
        Specified by:
        writeBuffer in interface org.apache.sshd.common.io.IoSession
      • getService

        public org.apache.sshd.common.io.IoService getService()
        Specified by:
        getService in interface org.apache.sshd.common.io.IoSession
      • suspendRead

        public void suspendRead()
        Specified by:
        suspendRead in interface org.apache.sshd.common.io.IoSession
      • resumeRead

        public void resumeRead()
        Specified by:
        resumeRead in interface org.apache.sshd.common.io.IoSession
      • shutdownOutputStream

        public void shutdownOutputStream()
                                  throws java.io.IOException
        Specified by:
        shutdownOutputStream in interface org.apache.sshd.common.io.IoSession
        Throws:
        java.io.IOException
      • suspend

        public void suspend()
        Intended for tests simulating a sudden connection drop only! Do not call otherwise.
      • doCloseGracefully

        protected org.apache.sshd.common.future.CloseFuture doCloseGracefully()
        Overrides:
        doCloseGracefully in class org.apache.sshd.common.util.closeable.AbstractCloseable
      • doCloseImmediately

        protected void doCloseImmediately()
        Overrides:
        doCloseImmediately in class org.apache.sshd.common.util.closeable.AbstractCloseable
      • channelActive

        protected void channelActive​(io.netty.channel.ChannelHandlerContext ctx)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • channelInactive

        protected void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • channelRead

        protected void channelRead​(io.netty.channel.ChannelHandlerContext ctx,
                                   org.apache.sshd.common.util.Readable msg)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • exceptionCaught

        protected void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                       java.lang.Throwable cause)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object