Package com.google.code.yanf4j.core
Interface Session
-
- All Known Subinterfaces:
ClosedMemcachedSession,MemcachedSession,NioSession
- All Known Implementing Classes:
AbstractNioSession,AbstractSession,ClosedMemcachedTCPSession,MemcachedTCPSession,NioTCPSession
public interface SessionAbstract connection
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSession.SessionStatus
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearAttributes()Clear attributesvoidclose()Close sessionvoidflush()Flush the write queue,this method may be no effect if OP_WRITE is running.java.lang.ObjectgetAttribute(java.lang.String key)Return attribute associated with keyCodecFactory.DecodergetDecoder()Return current decoderCodecFactory.EncodergetEncoder()Return current encoderHandlergetHandler()longgetLastOperationTimeStamp()Return last operation timestamp,operation include read,write,idlejava.net.InetAddressgetLocalAddress()java.nio.ByteOrdergetReadBufferByteOrder()Return the session read buffer's byte order,big end or little end.java.net.InetSocketAddressgetRemoteSocketAddress()Return the remote end's InetSocketAddresslonggetScheduleWritenBytes()Return the bytes in write queue,there bytes is in memory.Use this method to controll writing speed.longgetSessionIdleTimeout()longgetSessionTimeout()booleanisClosed()Check if session is closedbooleanisExpired()Return 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.booleanisHandleReadWriteConcurrently()Return true if allow handling read and write concurrently,default is true.booleanisIdle()Check if session is idlebooleanisLoopbackConnection()return true if it is a loopback connectionbooleanisUseBlockingRead()Return true if using blocking readbooleanisUseBlockingWrite()Return true if using blocking writevoidremoveAttribute(java.lang.String key)Remove attributevoidsetAttribute(java.lang.String key, java.lang.Object value)Set a attribute attched with this sessionjava.lang.ObjectsetAttributeIfAbsent(java.lang.String key, java.lang.Object value)voidsetDecoder(CodecFactory.Decoder decoder)voidsetEncoder(CodecFactory.Encoder encoder)Set encodervoidsetHandleReadWriteConcurrently(boolean handleReadWriteConcurrently)voidsetReadBufferByteOrder(java.nio.ByteOrder readBufferByteOrder)voidsetSessionIdleTimeout(long sessionIdleTimeout)voidsetSessionTimeout(long sessionTimeout)voidsetUseBlockingRead(boolean useBlockingRead)voidsetUseBlockingWrite(boolean useBlockingWrite)Set if using blocking writevoidstart()Start sessionvoidwrite(java.lang.Object packet)Write a message,if you don't care when the message is written
-
-
-
Method Detail
-
start
void start()
Start session
-
write
void write(java.lang.Object packet)
Write a message,if you don't care when the message is written- Parameters:
packet-
-
isClosed
boolean isClosed()
Check if session is closed- Returns:
-
close
void close()
Close session
-
getRemoteSocketAddress
java.net.InetSocketAddress getRemoteSocketAddress()
Return the remote end's InetSocketAddress- Returns:
-
getLocalAddress
java.net.InetAddress getLocalAddress()
-
isUseBlockingWrite
boolean isUseBlockingWrite()
Return true if using blocking write- Returns:
-
setUseBlockingWrite
void setUseBlockingWrite(boolean useBlockingWrite)
Set if using blocking write- Parameters:
useBlockingWrite-
-
isUseBlockingRead
boolean isUseBlockingRead()
Return true if using blocking read- Returns:
-
setUseBlockingRead
void setUseBlockingRead(boolean useBlockingRead)
-
flush
void flush()
Flush the write queue,this method may be no effect if OP_WRITE is running.
-
isExpired
boolean isExpired()
Return 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.- Returns:
-
isIdle
boolean isIdle()
Check if session is idle- Returns:
-
getEncoder
CodecFactory.Encoder getEncoder()
Return current encoder- Returns:
-
setEncoder
void setEncoder(CodecFactory.Encoder encoder)
Set encoder- Parameters:
encoder-
-
getDecoder
CodecFactory.Decoder getDecoder()
Return current decoder- Returns:
-
setDecoder
void setDecoder(CodecFactory.Decoder decoder)
-
isHandleReadWriteConcurrently
boolean isHandleReadWriteConcurrently()
Return true if allow handling read and write concurrently,default is true.- Returns:
-
setHandleReadWriteConcurrently
void setHandleReadWriteConcurrently(boolean handleReadWriteConcurrently)
-
getReadBufferByteOrder
java.nio.ByteOrder getReadBufferByteOrder()
Return the session read buffer's byte order,big end or little end.- Returns:
-
setReadBufferByteOrder
void setReadBufferByteOrder(java.nio.ByteOrder readBufferByteOrder)
-
setAttribute
void setAttribute(java.lang.String key, java.lang.Object value)Set a attribute attched with this session- Parameters:
key-value-
-
removeAttribute
void removeAttribute(java.lang.String key)
Remove attribute- Parameters:
key-
-
getAttribute
java.lang.Object getAttribute(java.lang.String key)
Return attribute associated with key- Parameters:
key-- Returns:
-
clearAttributes
void clearAttributes()
Clear attributes
-
getScheduleWritenBytes
long getScheduleWritenBytes()
Return the bytes in write queue,there bytes is in memory.Use this method to controll writing speed.- Returns:
-
getLastOperationTimeStamp
long getLastOperationTimeStamp()
Return last operation timestamp,operation include read,write,idle- Returns:
-
isLoopbackConnection
boolean isLoopbackConnection()
return true if it is a loopback connection- Returns:
-
getSessionIdleTimeout
long getSessionIdleTimeout()
-
setSessionIdleTimeout
void setSessionIdleTimeout(long sessionIdleTimeout)
-
getSessionTimeout
long getSessionTimeout()
-
setSessionTimeout
void setSessionTimeout(long sessionTimeout)
-
setAttributeIfAbsent
java.lang.Object setAttributeIfAbsent(java.lang.String key, java.lang.Object value)
-
getHandler
Handler getHandler()
-
-