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 booleanallowReconnectprivate booleanauthFailedprivate BufferAllocatorbufferAllocatorprotected java.util.concurrent.BlockingQueue<Command>commandAlreadySentCommand which are already sentprivate CommandFactorycommandFactoryprivate java.util.concurrent.atomic.AtomicReference<Command>currentCommandprivate InetSocketAddressWrapperinetSocketAddressWrapperprivate MemcachedOptimizeroptimiezerprivate java.net.SocketAddressremoteSocketAddressprivate intsendBufferSize-
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 voidaddCommand(Command command)voiddestroy()BufferAllocatorgetBufferAllocator()CommandgetCurrentCommand()InetSocketAddressWrappergetInetSocketAddressWrapper()intgetOrder()java.net.InetSocketAddressgetRemoteSocketAddress()Return the remote end's InetSocketAddressintgetWeight()booleanisAllowReconnect()is allow auto recconect if closed?booleanisAuthFailed()protected WriteMessagepreprocessWriteMessage(WriteMessage writeMessage)Pre-Process WriteMessage before writing to channelvoidquit()voidsetAllowReconnect(boolean reconnected)voidsetAuthFailed(boolean authFailed)voidsetBufferAllocator(BufferAllocator bufferAllocator)voidsetCurrentCommand(Command cmd)voidsetInetSocketAddressWrapper(InetSocketAddressWrapper inetSocketAddressWrapper)voidtakeCurrentCommand()private CommandtakeExecutingCommand()get current command from queuejava.lang.StringtoString()protected WriteMessagewrapMessage(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:
getInetSocketAddressWrapperin interfaceClosedMemcachedSession
-
getOrder
public int getOrder()
- Specified by:
getOrderin interfaceClosedMemcachedSession
-
getWeight
public int getWeight()
- Specified by:
getWeightin interfaceClosedMemcachedSession
-
setInetSocketAddressWrapper
public void setInetSocketAddressWrapper(InetSocketAddressWrapper inetSocketAddressWrapper)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
destroy
public void destroy()
- Specified by:
destroyin interfaceMemcachedSession
-
getRemoteSocketAddress
public java.net.InetSocketAddress getRemoteSocketAddress()
Description copied from interface:SessionReturn the remote end's InetSocketAddress- Specified by:
getRemoteSocketAddressin interfaceSession- Overrides:
getRemoteSocketAddressin classNioTCPSession- Returns:
-
preprocessWriteMessage
protected WriteMessage preprocessWriteMessage(WriteMessage writeMessage)
Description copied from class:AbstractSessionPre-Process WriteMessage before writing to channel- Overrides:
preprocessWriteMessagein classAbstractSession- Returns:
-
isAuthFailed
public boolean isAuthFailed()
- Specified by:
isAuthFailedin interfaceMemcachedSession
-
setAuthFailed
public void setAuthFailed(boolean authFailed)
- Specified by:
setAuthFailedin interfaceMemcachedSession
-
getBufferAllocator
public final BufferAllocator getBufferAllocator()
-
setBufferAllocator
public final void setBufferAllocator(BufferAllocator bufferAllocator)
- Specified by:
setBufferAllocatorin interfaceMemcachedSession
-
wrapMessage
protected final WriteMessage wrapMessage(java.lang.Object msg, java.util.concurrent.Future<java.lang.Boolean> writeFuture)
- Overrides:
wrapMessagein classNioTCPSession
-
takeExecutingCommand
private Command takeExecutingCommand()
get current command from queue- Returns:
-
isAllowReconnect
public boolean isAllowReconnect()
is allow auto recconect if closed?- Specified by:
isAllowReconnectin interfaceClosedMemcachedSession- Returns:
-
setAllowReconnect
public void setAllowReconnect(boolean reconnected)
- Specified by:
setAllowReconnectin 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:
quitin interfaceMemcachedSession
-
-