Package net.rubyeye.xmemcached.impl
Class MemcachedTCPSession
- java.lang.Object
-
- com.google.code.yanf4j.core.impl.AbstractSession
-
- com.google.code.yanf4j.nio.impl.AbstractNioSession
-
- com.google.code.yanf4j.nio.impl.NioTCPSession
-
- net.rubyeye.xmemcached.impl.MemcachedTCPSession
-
- All Implemented Interfaces:
Session
,NioSession
,ClosedMemcachedSession
,MemcachedSession
public class MemcachedTCPSession extends NioTCPSession implements MemcachedSession
Connected session for a memcached server
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.code.yanf4j.core.Session
Session.SessionStatus
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowReconnect
private boolean
authFailed
private BufferAllocator
bufferAllocator
protected java.util.concurrent.BlockingQueue<Command>
commandAlreadySent
Command which are already sentprivate CommandFactory
commandFactory
private java.util.concurrent.atomic.AtomicReference<Command>
currentCommand
private InetSocketAddressWrapper
inetSocketAddressWrapper
private MemcachedOptimizer
optimiezer
private java.net.SocketAddress
remoteSocketAddress
private int
sendBufferSize
-
Fields inherited from class com.google.code.yanf4j.nio.impl.AbstractNioSession
selectableChannel, selectorManager
-
Fields 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 Constructor Description MemcachedTCPSession(NioSessionConfig sessionConfig, int readRecvBufferSize, MemcachedOptimizer optimiezer, int readThreadCount, CommandFactory commandFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommand(Command command)
void
destroy()
BufferAllocator
getBufferAllocator()
Command
getCurrentCommand()
InetSocketAddressWrapper
getInetSocketAddressWrapper()
int
getOrder()
java.net.InetSocketAddress
getRemoteSocketAddress()
Return the remote end's InetSocketAddressint
getWeight()
boolean
isAllowReconnect()
is allow auto recconect if closed?boolean
isAuthFailed()
protected WriteMessage
preprocessWriteMessage(WriteMessage writeMessage)
Pre-Process WriteMessage before writing to channelvoid
quit()
void
setAllowReconnect(boolean reconnected)
void
setAuthFailed(boolean authFailed)
void
setBufferAllocator(BufferAllocator bufferAllocator)
void
setCurrentCommand(Command cmd)
void
setInetSocketAddressWrapper(InetSocketAddressWrapper inetSocketAddressWrapper)
void
takeCurrentCommand()
private Command
takeExecutingCommand()
get current command from queuejava.lang.String
toString()
protected WriteMessage
wrapMessage(java.lang.Object msg, java.util.concurrent.Future<java.lang.Boolean> writeFuture)
-
Methods inherited from class com.google.code.yanf4j.nio.impl.NioTCPSession
blockingRead, blockingWrite, closeChannel, decode, isExpired, readFromBuffer, socket, writeToChannel
-
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, writeFromUserCode
-
Methods 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, removeAttribute, setAttribute, setAttributeIfAbsent, setClosed, setDecoder, setEncoder, setHandleReadWriteConcurrently, setReadBuffer, setReadBufferByteOrder, setSessionIdleTimeout, setSessionTimeout, setUseBlockingRead, setUseBlockingWrite, start, transferFrom, transferTo, updateTimeStamp, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.code.yanf4j.core.Session
clearAttributes, close, flush, getAttribute, getDecoder, getEncoder, getHandler, getLastOperationTimeStamp, getLocalAddress, getReadBufferByteOrder, getScheduleWritenBytes, getSessionIdleTimeout, getSessionTimeout, isClosed, isExpired, isHandleReadWriteConcurrently, isIdle, isLoopbackConnection, isUseBlockingRead, isUseBlockingWrite, removeAttribute, setAttribute, setAttributeIfAbsent, setDecoder, setEncoder, setHandleReadWriteConcurrently, setReadBufferByteOrder, setSessionIdleTimeout, setSessionTimeout, setUseBlockingRead, setUseBlockingWrite, start, write
-
-
-
-
Field Detail
-
commandAlreadySent
protected java.util.concurrent.BlockingQueue<Command> commandAlreadySent
Command which are already sent
-
currentCommand
private final java.util.concurrent.atomic.AtomicReference<Command> currentCommand
-
remoteSocketAddress
private java.net.SocketAddress remoteSocketAddress
-
sendBufferSize
private int sendBufferSize
-
optimiezer
private final MemcachedOptimizer optimiezer
-
allowReconnect
private boolean allowReconnect
-
authFailed
private volatile boolean authFailed
-
commandFactory
private final CommandFactory commandFactory
-
inetSocketAddressWrapper
private InetSocketAddressWrapper inetSocketAddressWrapper
-
bufferAllocator
private BufferAllocator bufferAllocator
-
-
Constructor Detail
-
MemcachedTCPSession
public MemcachedTCPSession(NioSessionConfig sessionConfig, int readRecvBufferSize, MemcachedOptimizer optimiezer, int readThreadCount, CommandFactory commandFactory)
-
-
Method Detail
-
getInetSocketAddressWrapper
public InetSocketAddressWrapper getInetSocketAddressWrapper()
- Specified by:
getInetSocketAddressWrapper
in interfaceClosedMemcachedSession
-
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceClosedMemcachedSession
-
getWeight
public int getWeight()
- Specified by:
getWeight
in interfaceClosedMemcachedSession
-
setInetSocketAddressWrapper
public void setInetSocketAddressWrapper(InetSocketAddressWrapper inetSocketAddressWrapper)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceMemcachedSession
-
getRemoteSocketAddress
public java.net.InetSocketAddress getRemoteSocketAddress()
Description copied from interface:Session
Return the remote end's InetSocketAddress- Specified by:
getRemoteSocketAddress
in interfaceSession
- Overrides:
getRemoteSocketAddress
in classNioTCPSession
- Returns:
-
preprocessWriteMessage
protected WriteMessage preprocessWriteMessage(WriteMessage writeMessage)
Description copied from class:AbstractSession
Pre-Process WriteMessage before writing to channel- Overrides:
preprocessWriteMessage
in classAbstractSession
- Returns:
-
isAuthFailed
public boolean isAuthFailed()
- Specified by:
isAuthFailed
in interfaceMemcachedSession
-
setAuthFailed
public void setAuthFailed(boolean authFailed)
- Specified by:
setAuthFailed
in interfaceMemcachedSession
-
getBufferAllocator
public final BufferAllocator getBufferAllocator()
-
setBufferAllocator
public final void setBufferAllocator(BufferAllocator bufferAllocator)
- Specified by:
setBufferAllocator
in interfaceMemcachedSession
-
wrapMessage
protected final WriteMessage wrapMessage(java.lang.Object msg, java.util.concurrent.Future<java.lang.Boolean> writeFuture)
- Overrides:
wrapMessage
in classNioTCPSession
-
takeExecutingCommand
private Command takeExecutingCommand()
get current command from queue- Returns:
-
isAllowReconnect
public boolean isAllowReconnect()
is allow auto recconect if closed?- Specified by:
isAllowReconnect
in interfaceClosedMemcachedSession
- Returns:
-
setAllowReconnect
public void setAllowReconnect(boolean reconnected)
- Specified by:
setAllowReconnect
in interfaceClosedMemcachedSession
-
addCommand
public void addCommand(Command command)
-
setCurrentCommand
public void setCurrentCommand(Command cmd)
-
getCurrentCommand
public Command getCurrentCommand()
-
takeCurrentCommand
public void takeCurrentCommand()
-
quit
public void quit()
- Specified by:
quit
in interfaceMemcachedSession
-
-