Class Nio2Session
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.common.io.nio2.Nio2Session
- All Implemented Interfaces:
Closeable, AutoCloseable, Channel, org.apache.sshd.common.Closeable, org.apache.sshd.common.io.IoSession, org.apache.sshd.common.util.net.ConnectionEndpointsIndicator
public class Nio2Session
extends org.apache.sshd.common.util.closeable.AbstractCloseable
implements org.apache.sshd.common.io.IoSession
- Author:
- Apache MINA SSHD Project
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable.State -
Field Summary
FieldsFields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, stateFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
ConstructorsConstructorDescriptionNio2Session(Nio2Service service, org.apache.sshd.common.PropertyResolver propertyResolver, org.apache.sshd.common.io.IoHandler handler, AsynchronousSocketChannel socket, SocketAddress acceptanceAddress) -
Method Summary
Modifier and TypeMethodDescriptionprotected Nio2CompletionHandler<Integer, Object> createReadCycleCompletionHandler(ByteBuffer buffer, org.apache.sshd.common.util.Readable bufReader) protected Nio2CompletionHandler<Integer, Object> createWriteCycleCompletionHandler(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer) protected org.apache.sshd.common.future.CloseFutureprotected voidprotected voiddoReadCycle(ByteBuffer buffer, Nio2CompletionHandler<Integer, Object> completion) protected voiddoReadCycle(ByteBuffer buffer, org.apache.sshd.common.util.Readable bufReader) protected voiddoShutdownOutputStream(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket) protected voiddoWriteCycle(ByteBuffer buffer, Nio2CompletionHandler<Integer, Object> completion) protected voidexceptionCaught(Throwable exc) protected voidfinishWrite(Nio2DefaultIoWriteFuture future) getAttribute(Object key) longgetId()org.apache.sshd.common.io.IoHandlerprotected voidhandleCompletedWriteCycle(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) protected voidhandleReadCycleCompletion(ByteBuffer buffer, org.apache.sshd.common.util.Readable bufReader, Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) protected voidhandleReadCycleFailure(ByteBuffer buffer, org.apache.sshd.common.util.Readable bufReader, Throwable exc, Object attachment) protected voidhandleWriteCycleFailure(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Throwable exc, Object attachment) removeAttribute(Object key) voidsetAttribute(Object key, Object value) setAttributeIfAbsent(Object key, Object value) voidvoidvoidstartReading(byte[] buf) voidstartReading(byte[] buf, int offset, int len) voidstartReading(int bufSize) voidstartReading(ByteBuffer buffer) protected voidvoidsuspend()Intended for tests simulating a sudden connection drop only!voidtoString()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, removeCloseFutureListenerMethods 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, warnMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, isClosed, isClosing, isOpen, removeCloseFutureListenerMethods inherited from interface org.apache.sshd.common.io.IoSession
close
-
Field Details
-
DEFAULT_READBUF_SIZE
public static final int DEFAULT_READBUF_SIZE- See Also:
-
-
Constructor Details
-
Nio2Session
public Nio2Session(Nio2Service service, org.apache.sshd.common.PropertyResolver propertyResolver, org.apache.sshd.common.io.IoHandler handler, AsynchronousSocketChannel socket, SocketAddress acceptanceAddress) throws IOException - Throws:
IOException
-
-
Method Details
-
getId
public long getId()- Specified by:
getIdin interfaceorg.apache.sshd.common.io.IoSession
-
getAttribute
-
setAttribute
-
setAttributeIfAbsent
-
removeAttribute
-
getRemoteAddress
- Specified by:
getRemoteAddressin interfaceorg.apache.sshd.common.util.net.ConnectionEndpointsIndicator
-
getLocalAddress
- Specified by:
getLocalAddressin interfaceorg.apache.sshd.common.util.net.ConnectionEndpointsIndicator
-
getAcceptanceAddress
- Specified by:
getAcceptanceAddressin interfaceorg.apache.sshd.common.io.IoSession
-
getSocket
-
getIoHandler
public org.apache.sshd.common.io.IoHandler getIoHandler() -
suspend
public void suspend()Intended for tests simulating a sudden connection drop only! Do not call otherwise. -
writeBuffer
public org.apache.sshd.common.io.IoWriteFuture writeBuffer(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException - Specified by:
writeBufferin interfaceorg.apache.sshd.common.io.IoSession- Throws:
IOException
-
exceptionCaught
-
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
-
getService
- Specified by:
getServicein interfaceorg.apache.sshd.common.io.IoSession
-
shutdownOutputStream
- Specified by:
shutdownOutputStreamin interfaceorg.apache.sshd.common.io.IoSession- Throws:
IOException
-
doShutdownOutputStream
protected void doShutdownOutputStream(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket) throws IOException - Throws:
IOException
-
startReading
public void startReading() -
startReading
public void startReading(int bufSize) -
startReading
public void startReading(byte[] buf) -
startReading
public void startReading(byte[] buf, int offset, int len) -
startReading
-
doReadCycle
-
createReadCycleCompletionHandler
protected Nio2CompletionHandler<Integer,Object> createReadCycleCompletionHandler(ByteBuffer buffer, org.apache.sshd.common.util.Readable bufReader) -
handleReadCycleCompletion
protected void handleReadCycleCompletion(ByteBuffer buffer, org.apache.sshd.common.util.Readable bufReader, Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) -
handleReadCycleFailure
protected void handleReadCycleFailure(ByteBuffer buffer, org.apache.sshd.common.util.Readable bufReader, Throwable exc, Object attachment) -
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
-
doReadCycle
-
startWriting
protected void startWriting() -
doWriteCycle
-
createWriteCycleCompletionHandler
protected Nio2CompletionHandler<Integer,Object> createWriteCycleCompletionHandler(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer) -
handleCompletedWriteCycle
protected void handleCompletedWriteCycle(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Nio2CompletionHandler<Integer, Object> completionHandler, Integer result, Object attachment) -
handleWriteCycleFailure
protected void handleWriteCycleFailure(Nio2DefaultIoWriteFuture future, AsynchronousSocketChannel socket, ByteBuffer buffer, int writeLen, Throwable exc, Object attachment) -
finishWrite
-
toString
-