Class MemcachedConnector
java.lang.Object
com.google.code.yanf4j.core.impl.AbstractController
com.google.code.yanf4j.nio.impl.NioController
com.google.code.yanf4j.nio.impl.SocketChannelController
net.rubyeye.xmemcached.impl.MemcachedConnector
- All Implemented Interfaces:
Controller, ControllerLifeCycle, SelectionKeyHandler, Connector
Connected session manager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classInner state listenner,manage session monitor.(package private) classSession monitor for healing sessions. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BufferAllocatorprivate final CommandFactoryprivate intprivate booleanprivate booleanprivate final FlowControlprivate longprivate final MemcachedOptimizerprotected Protocolprivate final Randomprivate final Set<InetSocketAddress> protected MemcachedSessionComparatorprotected MemcachedSessionLocatorprotected final ConcurrentHashMap<InetSocketAddress, Queue<Session>> private final MemcachedConnector.SessionMonitorprivate booleanprivate final ConcurrentHashMap<InetSocketAddress, List<Session>> private final DelayQueue<ReconnectRequest> Fields inherited from class SocketChannelController
soLingerOnFields inherited from class NioController
selectorManager, selectorPoolSizeFields inherited from class AbstractController
codecFactory, configuration, dispatchMessageDispatcher, dispatchMessageThreadCount, handler, handleReadWriteConcurrently, localSocketAddress, log, readEventDispatcher, readThreadCount, sessionSet, sessionTimeout, socketOptions, soTimeout, started, stateListeners, statistics, statisticsInterval, writeEventDispatcher, writeThreadCount -
Constructor Summary
ConstructorsConstructorDescriptionMemcachedConnector(Configuration configuration, MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddMainSession(Session session, InetSocketAddress lastReolvedAddr, InetSocketAddressWrapper addrWrapper) voidaddSession(Session session) private voidaddStandbySession(Session session, InetSocketAddress mainNodeAddress, InetSocketAddress lastResolvedMainAddr, InetSocketAddressWrapper addrWrapper) voidaddToWatingQueue(ReconnectRequest request) protected Queue<WriteMessage> Build write queue for sessionprotected NioSessionprivate voidcancelKey(SelectionKey key) voidcloseChannel(Selector selector) connect(InetSocketAddressWrapper addressWrapper) protected MemcachedTCPSessioncreateSession(SocketChannel socketChannel, InetSocketAddressWrapper wrapper) protected voiddoStart()Inner startupfinal SessionfindSessionByKey(String key) private MemcachedSessionfindStandbySession(MemcachedSession session) longReturns the noreply operations flow control manager.Get session by InetSocketAddressgetSessionListBySocketAddress(InetSocketAddress inetSocketAddress) Returns main node's standby session list.voidonConnect(SelectionKey key) voidMake all connection sending a quit command to memcachedprivate voidremoveMainSession(Session session) voidremoveReconnectRequest(InetSocketAddress inetSocketAddress) voidremoveSession(Session session) private voidremoveStandbySession(Session session, InetSocketAddress mainNodeAddr) voidsetBufferAllocator(BufferAllocator allocator) final voidsetConnectionPoolSize(int poolSize) voidsetEnableHealSession(boolean enableHealSession) voidsetFailureMode(boolean failureMode) final voidsetHealSessionInterval(long healConnectionInterval) voidsetMergeFactor(int mergeFactor) voidsetOptimizeGet(boolean optimiezeGet) voidsetOptimizeMergeBuffer(boolean optimizeMergeBuffer) voidsetSessionComparator(MemcachedSessionComparator sessionComparator) voidsetSessionLocator(MemcachedSessionLocator sessionLocator) voidfinal voidMethods inherited from class SocketChannelController
configureSocketChannel, dispatchReadEvent, dispatchWriteEvent, setSoLingerMethods inherited from class NioController
bind, buildSessionConfig, closeSelectionKey, getSelectorManager, getSelectorPoolSize, initialSelectorManager, onRead, onWrite, setSelectorPoolSize, start0, stop0Methods inherited from class AbstractController
addStateListener, bind, checkStatisticsForRestart, getCodecFactory, getConfiguration, getDispatchMessageThreadCount, getHandler, getLocalSocketAddress, getPort, getReadThreadCount, getReceiveThroughputLimit, getSendThroughputLimit, getSessionIdleTimeout, getSessionTimeout, getSocketOption, getSoTimeout, getStatistics, getWriteThreadCount, isHandleReadWriteConcurrently, isStarted, notifyAllSessionClosed, notifyException, notifyReady, notifyStarted, notifyStopped, onAccept, registerSession, removeStateListener, setCodecFactory, setConfiguration, setDispatchMessageThreadCount, setHandler, setHandleReadWriteConcurrently, setLocalSocketAddress, setReadThreadCount, setReceiveThroughputLimit, setSendThroughputLimit, setSessionIdleTimeout, setSessionTimeout, setSocketOption, setSocketOptions, setSoTimeout, setWriteThreadCount, start, stop, unregisterSessionMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Connector
setSocketOptionsMethods inherited from interface Controller
addStateListener, getCodecFactory, getDispatchMessageThreadCount, getHandler, getLocalSocketAddress, getPort, getReadThreadCount, getReceiveThroughputLimit, getSendThroughputLimit, getSessionIdleTimeout, getSessionTimeout, getSoTimeout, getStatistics, getWriteThreadCount, isHandleReadWriteConcurrently, isStarted, removeStateListener, setCodecFactory, setDispatchMessageThreadCount, setHandler, setHandleReadWriteConcurrently, setLocalSocketAddress, setReadThreadCount, setReceiveThroughputLimit, setSendThroughputLimit, setSessionIdleTimeout, setSessionTimeout, setSocketOption, setSoTimeout, setWriteThreadCount, start, stopMethods inherited from interface SelectionKeyHandler
onAccept
-
Field Details
-
waitingQueue
-
bufferAllocator
-
removedAddrSet
-
optimiezer
-
healSessionInterval
private long healSessionInterval -
connectionPoolSize
private int connectionPoolSize -
protocol
-
enableHealSession
private boolean enableHealSession -
commandFactory
-
failureMode
private boolean failureMode -
standbySessionMap
-
flowControl
-
shuttingDown
private volatile boolean shuttingDown -
sessionLocator
-
sessionComparator
-
sessionMap
-
random
-
sessionMonitor
-
-
Constructor Details
-
MemcachedConnector
public MemcachedConnector(Configuration configuration, MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations)
-
-
Method Details
-
shuttingDown
public void shuttingDown() -
setSessionLocator
- Specified by:
setSessionLocatorin interfaceConnector
-
setSessionComparator
- Specified by:
setSessionComparatorin interfaceConnector
-
setEnableHealSession
public void setEnableHealSession(boolean enableHealSession) - Specified by:
setEnableHealSessionin interfaceConnector
-
getReconnectRequestQueue
- Specified by:
getReconnectRequestQueuein interfaceConnector
-
getSessionSet
- Specified by:
getSessionSetin interfaceConnector- Overrides:
getSessionSetin classAbstractController
-
setHealSessionInterval
public final void setHealSessionInterval(long healConnectionInterval) - Specified by:
setHealSessionIntervalin interfaceConnector
-
getHealSessionInterval
public long getHealSessionInterval()- Specified by:
getHealSessionIntervalin interfaceConnector
-
setOptimizeGet
public void setOptimizeGet(boolean optimiezeGet) - Specified by:
setOptimizeGetin interfaceConnector
-
setOptimizeMergeBuffer
public void setOptimizeMergeBuffer(boolean optimizeMergeBuffer) - Specified by:
setOptimizeMergeBufferin interfaceConnector
-
getProtocol
-
addSession
-
addMainSession
private void addMainSession(Session session, InetSocketAddress lastReolvedAddr, InetSocketAddressWrapper addrWrapper) -
addStandbySession
private void addStandbySession(Session session, InetSocketAddress mainNodeAddress, InetSocketAddress lastResolvedMainAddr, InetSocketAddressWrapper addrWrapper) -
getSessionListBySocketAddress
-
removeReconnectRequest
- Specified by:
removeReconnectRequestin interfaceConnector
-
updateSessions
public final void updateSessions()- Specified by:
updateSessionsin interfaceConnector
-
removeSession
- Specified by:
removeSessionin interfaceConnector
-
removeMainSession
-
removeStandbySession
-
doStart
Description copied from class:NioControllerInner startup- Specified by:
doStartin classNioController- Throws:
IOException
-
onConnect
- Specified by:
onConnectin interfaceSelectionKeyHandler- Overrides:
onConnectin classAbstractController- Throws:
IOException
-
cancelKey
- Throws:
IOException
-
createSession
protected MemcachedTCPSession createSession(SocketChannel socketChannel, InetSocketAddressWrapper wrapper) -
addToWatingQueue
- Specified by:
addToWatingQueuein interfaceConnector
-
connect
-
closeChannel
- Specified by:
closeChannelin interfaceSelectionKeyHandler- Throws:
IOException
-
send
- Specified by:
sendin interfaceConnector- Throws:
MemcachedException
-
findStandbySession
-
getStandbySessionListByMainNodeAddr
Returns main node's standby session list.- Specified by:
getStandbySessionListByMainNodeAddrin interfaceConnector- Parameters:
addr-- Returns:
-
findSessionByKey
-
getSessionByAddress
Get session by InetSocketAddress- Specified by:
getSessionByAddressin interfaceConnector- Parameters:
addr-- Returns:
-
setConnectionPoolSize
public final void setConnectionPoolSize(int poolSize) - Specified by:
setConnectionPoolSizein interfaceConnector
-
setMergeFactor
public void setMergeFactor(int mergeFactor) - Specified by:
setMergeFactorin interfaceConnector
-
getNoReplyOpsFlowControl
Description copied from interface:ConnectorReturns the noreply operations flow control manager.- Specified by:
getNoReplyOpsFlowControlin interfaceConnector- Returns:
-
buildSession
- Overrides:
buildSessionin classSocketChannelController
-
buildQueue
Build write queue for session- Overrides:
buildQueuein classAbstractController- Returns:
-
getBufferAllocator
-
quitAllSessions
public void quitAllSessions()Description copied from interface:ConnectorMake all connection sending a quit command to memcached- Specified by:
quitAllSessionsin interfaceConnector
-
setFailureMode
public void setFailureMode(boolean failureMode) - Specified by:
setFailureModein interfaceConnector
-
setBufferAllocator
- Specified by:
setBufferAllocatorin interfaceConnector
-
getServerAddresses
-