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 Session
Abstract connection
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear attributesvoid
close()
Close sessionvoid
flush()
Flush the write queue,this method may be no effect if OP_WRITE is running.getAttribute
(String key) Return attribute associated with keyReturn current decoderReturn current encoderlong
Return last operation timestamp,operation include read,write,idleReturn the session read buffer's byte order,big end or little end.Return the remote end's InetSocketAddresslong
Return the bytes in write queue,there bytes is in memory.Use this method to controll writing speed.long
long
boolean
isClosed()
Check if session is closedboolean
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.boolean
Return true if allow handling read and write concurrently,default is true.boolean
isIdle()
Check if session is idleboolean
return true if it is a loopback connectionboolean
Return true if using blocking readboolean
Return true if using blocking writevoid
removeAttribute
(String key) Remove attributevoid
setAttribute
(String key, Object value) Set a attribute attched with this sessionsetAttributeIfAbsent
(String key, Object value) void
setDecoder
(CodecFactory.Decoder decoder) void
setEncoder
(CodecFactory.Encoder encoder) Set encodervoid
setHandleReadWriteConcurrently
(boolean handleReadWriteConcurrently) void
setReadBufferByteOrder
(ByteOrder readBufferByteOrder) void
setSessionIdleTimeout
(long sessionIdleTimeout) void
setSessionTimeout
(long sessionTimeout) void
setUseBlockingRead
(boolean useBlockingRead) void
setUseBlockingWrite
(boolean useBlockingWrite) Set if using blocking writevoid
start()
Start sessionvoid
Write a message,if you don't care when the message is written
-
Method Details
-
start
void start()Start session -
write
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
InetSocketAddress getRemoteSocketAddress()Return the remote end's InetSocketAddress- Returns:
-
getLocalAddress
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
Set encoder- Parameters:
encoder
-
-
getDecoder
CodecFactory.Decoder getDecoder()Return current decoder- Returns:
-
setDecoder
-
isHandleReadWriteConcurrently
boolean isHandleReadWriteConcurrently()Return true if allow handling read and write concurrently,default is true.- Returns:
-
setHandleReadWriteConcurrently
void setHandleReadWriteConcurrently(boolean handleReadWriteConcurrently) -
getReadBufferByteOrder
ByteOrder getReadBufferByteOrder()Return the session read buffer's byte order,big end or little end.- Returns:
-
setReadBufferByteOrder
-
setAttribute
Set a attribute attched with this session- Parameters:
key
-value
-
-
removeAttribute
Remove attribute- Parameters:
key
-
-
getAttribute
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
-
getHandler
Handler getHandler()
-