Package com.google.code.yanf4j.nio.impl
Class NioTCPSession
java.lang.Object
com.google.code.yanf4j.core.impl.AbstractSession
com.google.code.yanf4j.nio.impl.AbstractNioSession
com.google.code.yanf4j.nio.impl.NioTCPSession
- All Implemented Interfaces:
Session,NioSession
- Direct Known Subclasses:
MemcachedTCPSession
Nio tcp connection
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.code.yanf4j.core.Session
Session.SessionStatus -
Field Summary
FieldsFields inherited from class com.google.code.yanf4j.nio.impl.AbstractNioSession
selectableChannel, selectorManagerFields inherited from class com.google.code.yanf4j.core.impl.AbstractSession
attributes, closed, currentMessage, decoder, dispatchMessageDispatcher, encoder, handler, handleReadWriteConcurrently, lastOperationTimeStamp, log, loopback, readBuffer, scheduleWritenBytes, sessionIdleTimeout, sessionTimeout, statistics, useBlockingRead, useBlockingWrite, writeLock, writeQueue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final intBlocking read using temp selectorprotected final ObjectblockingWrite(SelectableChannel channel, WriteMessage message, IoBuffer writeBuffer) Blocking write using temp selectorprotected final voidvoiddecode()Decode bufferprivate voidReturn the remote end's InetSocketAddressfinal booleanReturn true if session is expired,session is expired beacause you set the sessionTimeout,if since session's last operation form now is over this vlaue,isExpired return true,and Handler.onExpired() will be invoked.protected voidsocket()protected WriteMessagewrapMessage(Object msg, Future<Boolean> writeFuture) protected ObjectwriteToChannel(WriteMessage message) Methods inherited from class com.google.code.yanf4j.nio.impl.AbstractNioSession
channel, doRealWrite, enableRead, enableWrite, flush, flush0, getLocalAddress, onEvent, onRead, onWrite, registerSession, schduleWriteMessage, start0, unregisterChannel, unregisterSession, writeFromUserCodeMethods inherited from class com.google.code.yanf4j.core.impl.AbstractSession
clearAttributes, clearWriteQueue, close, dispatchReceivedMessage, getAttribute, getDecoder, getDispatchMessageDispatcher, getEncoder, getHandler, getLastOperationTimeStamp, getReadBuffer, getReadBufferByteOrder, getScheduleWritenBytes, getSessionIdleTimeout, getSessionTimeout, getStatistics, getWriteLock, getWriteQueue, isClosed, isHandleReadWriteConcurrently, isIdle, isLoopbackConnection, isUseBlockingRead, isUseBlockingWrite, onClosed, onConnected, onCreated, onException, onExpired, onIdle, onStarted, preprocessWriteMessage, removeAttribute, setAttribute, setAttributeIfAbsent, setClosed, setDecoder, setEncoder, setHandleReadWriteConcurrently, setReadBuffer, setReadBufferByteOrder, setSessionIdleTimeout, setSessionTimeout, setUseBlockingRead, setUseBlockingWrite, start, transferFrom, transferTo, updateTimeStamp, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.code.yanf4j.core.Session
clearAttributes, close, getAttribute, getDecoder, getEncoder, getHandler, getLastOperationTimeStamp, getReadBufferByteOrder, getScheduleWritenBytes, getSessionIdleTimeout, getSessionTimeout, isClosed, isHandleReadWriteConcurrently, isIdle, isLoopbackConnection, isUseBlockingRead, isUseBlockingWrite, removeAttribute, setAttribute, setAttributeIfAbsent, setDecoder, setEncoder, setHandleReadWriteConcurrently, setReadBufferByteOrder, setSessionIdleTimeout, setSessionTimeout, setUseBlockingRead, setUseBlockingWrite, start, write
-
Field Details
-
remoteAddress
-
-
Constructor Details
-
NioTCPSession
-
-
Method Details
-
isExpired
public final boolean isExpired()Description copied from interface:SessionReturn true if session is expired,session is expired beacause you set the sessionTimeout,if since session's last operation form now is over this vlaue,isExpired return true,and Handler.onExpired() will be invoked.- Specified by:
isExpiredin interfaceSession- Overrides:
isExpiredin classAbstractSession- Returns:
-
writeToChannel
- Specified by:
writeToChannelin classAbstractNioSession- Throws:
IOException
-
getRemoteSocketAddress
Description copied from interface:SessionReturn the remote end's InetSocketAddress- Returns:
-
blockingWrite
protected final Object blockingWrite(SelectableChannel channel, WriteMessage message, IoBuffer writeBuffer) throws IOException, ClosedChannelException Blocking write using temp selector- Parameters:
channel-message-writeBuffer-- Returns:
- Throws:
IOExceptionClosedChannelException
-
wrapMessage
- Specified by:
wrapMessagein classAbstractSession
-
readFromBuffer
protected void readFromBuffer()- Specified by:
readFromBufferin classAbstractNioSession
-
decodeAndDispatch
private void decodeAndDispatch() -
blockingRead
Blocking read using temp selector- Returns:
- Throws:
ClosedChannelExceptionIOException
-
decode
public void decode()Decode buffer- Specified by:
decodein classAbstractSession
-
socket
-
closeChannel
- Overrides:
closeChannelin classAbstractNioSession- Throws:
IOException
-