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 Modifier and Type Interface Description static class
Session.SessionStatus
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clearAttributes()
Clear attributesvoid
close()
Close sessionvoid
flush()
Flush the write queue,this method may be no effect if OP_WRITE is running.java.lang.Object
getAttribute(java.lang.String key)
Return attribute associated with keyCodecFactory.Decoder
getDecoder()
Return current decoderCodecFactory.Encoder
getEncoder()
Return current encoderHandler
getHandler()
long
getLastOperationTimeStamp()
Return last operation timestamp,operation include read,write,idlejava.net.InetAddress
getLocalAddress()
java.nio.ByteOrder
getReadBufferByteOrder()
Return the session read buffer's byte order,big end or little end.java.net.InetSocketAddress
getRemoteSocketAddress()
Return the remote end's InetSocketAddresslong
getScheduleWritenBytes()
Return the bytes in write queue,there bytes is in memory.Use this method to controll writing speed.long
getSessionIdleTimeout()
long
getSessionTimeout()
boolean
isClosed()
Check if session is closedboolean
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.boolean
isHandleReadWriteConcurrently()
Return true if allow handling read and write concurrently,default is true.boolean
isIdle()
Check if session is idleboolean
isLoopbackConnection()
return true if it is a loopback connectionboolean
isUseBlockingRead()
Return true if using blocking readboolean
isUseBlockingWrite()
Return true if using blocking writevoid
removeAttribute(java.lang.String key)
Remove attributevoid
setAttribute(java.lang.String key, java.lang.Object value)
Set a attribute attched with this sessionjava.lang.Object
setAttributeIfAbsent(java.lang.String key, java.lang.Object value)
void
setDecoder(CodecFactory.Decoder decoder)
void
setEncoder(CodecFactory.Encoder encoder)
Set encodervoid
setHandleReadWriteConcurrently(boolean handleReadWriteConcurrently)
void
setReadBufferByteOrder(java.nio.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(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()
-
-