Interface Session

All Known Subinterfaces:
ClosedMemcachedSession, MemcachedSession, NioSession
All Known Implementing Classes:
AbstractNioSession, AbstractSession, ClosedMemcachedTCPSession, MemcachedTCPSession, NioTCPSession

public interface Session
Abstract connection
  • Method Details

    • start

      void start()
      Start session
    • write

      void write(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

      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

      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

      ByteOrder getReadBufferByteOrder()
      Return the session read buffer's byte order,big end or little end.
      Returns:
    • setReadBufferByteOrder

      void setReadBufferByteOrder(ByteOrder readBufferByteOrder)
    • setAttribute

      void setAttribute(String key, Object value)
      Set a attribute attched with this session
      Parameters:
      key -
      value -
    • removeAttribute

      void removeAttribute(String key)
      Remove attribute
      Parameters:
      key -
    • getAttribute

      Object getAttribute(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

      Object setAttributeIfAbsent(String key, Object value)
    • getHandler

      Handler getHandler()