Package org.apache.sshd.netty
Class NettyIoSession
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.util.closeable.IoBaseCloseable
-
- org.apache.sshd.common.util.closeable.AbstractCloseable
-
- org.apache.sshd.netty.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.IoSessionThe Netty based IoSession implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classNettyIoSession.AdapterNetty adapter to use as a bridge, with extra handling for suspending reads.protected static classNettyIoSession.DefaultIoWriteFuture
-
Field Summary
Fields Modifier and Type Field Description private java.net.SocketAddressacceptanceAddressprotected io.netty.channel.ChannelInboundHandlerAdapteradapterprotected java.util.Map<java.lang.Object,java.lang.Object>attributesprotected io.netty.channel.ChannelHandlerContextcontextprotected org.apache.sshd.common.io.IoHandlerhandlerprotected longidprotected io.netty.channel.ChannelFutureprevprotected java.util.concurrent.atomic.AtomicBooleanreadSuspendedprotected java.net.SocketAddressremoteAddrprotected NettyIoServiceservice
-
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 voidchannelActive(io.netty.channel.ChannelHandlerContext ctx)protected voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)protected voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, org.apache.sshd.common.util.Readable msg)protected org.apache.sshd.common.future.CloseFuturedoCloseGracefully()protected voiddoCloseImmediately()protected voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)java.net.SocketAddressgetAcceptanceAddress()java.lang.ObjectgetAttribute(java.lang.Object key)longgetId()java.net.SocketAddressgetLocalAddress()java.net.SocketAddressgetRemoteAddress()org.apache.sshd.common.io.IoServicegetService()java.lang.ObjectremoveAttribute(java.lang.Object key)voidresumeRead()java.lang.ObjectsetAttribute(java.lang.Object key, java.lang.Object value)java.lang.ObjectsetAttributeIfAbsent(java.lang.Object key, java.lang.Object value)voidshutdownOutputStream()voidsuspend()Intended for tests simulating a sudden connection drop only! Do not call otherwise.voidsuspendRead()java.lang.StringtoString()org.apache.sshd.common.io.IoWriteFuturewriteBuffer(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
-
-
-
-
Field Detail
-
attributes
protected final java.util.Map<java.lang.Object,java.lang.Object> attributes
-
service
protected final NettyIoService service
-
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:
getIdin interfaceorg.apache.sshd.common.io.IoSession
-
getAttribute
public java.lang.Object getAttribute(java.lang.Object key)
- Specified by:
getAttributein interfaceorg.apache.sshd.common.io.IoSession
-
setAttribute
public java.lang.Object setAttribute(java.lang.Object key, java.lang.Object value)- Specified by:
setAttributein interfaceorg.apache.sshd.common.io.IoSession
-
setAttributeIfAbsent
public java.lang.Object setAttributeIfAbsent(java.lang.Object key, java.lang.Object value)- Specified by:
setAttributeIfAbsentin interfaceorg.apache.sshd.common.io.IoSession
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.Object key)
- Specified by:
removeAttributein interfaceorg.apache.sshd.common.io.IoSession
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress()
- Specified by:
getRemoteAddressin interfaceorg.apache.sshd.common.util.net.ConnectionEndpointsIndicator
-
getLocalAddress
public java.net.SocketAddress getLocalAddress()
- Specified by:
getLocalAddressin interfaceorg.apache.sshd.common.util.net.ConnectionEndpointsIndicator
-
getAcceptanceAddress
public java.net.SocketAddress getAcceptanceAddress()
- Specified by:
getAcceptanceAddressin interfaceorg.apache.sshd.common.io.IoSession
-
writeBuffer
public org.apache.sshd.common.io.IoWriteFuture writeBuffer(org.apache.sshd.common.util.buffer.Buffer buffer)
- Specified by:
writeBufferin interfaceorg.apache.sshd.common.io.IoSession
-
getService
public org.apache.sshd.common.io.IoService getService()
- Specified by:
getServicein interfaceorg.apache.sshd.common.io.IoSession
-
suspendRead
public void suspendRead()
- Specified by:
suspendReadin interfaceorg.apache.sshd.common.io.IoSession
-
resumeRead
public void resumeRead()
- Specified by:
resumeReadin interfaceorg.apache.sshd.common.io.IoSession
-
shutdownOutputStream
public void shutdownOutputStream() throws java.io.IOException- Specified by:
shutdownOutputStreamin interfaceorg.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:
doCloseGracefullyin classorg.apache.sshd.common.util.closeable.AbstractCloseable
-
doCloseImmediately
protected void doCloseImmediately()
- Overrides:
doCloseImmediatelyin classorg.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:
toStringin classjava.lang.Object
-
-