Package net.rubyeye.xmemcached.impl
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
public class MemcachedConnector extends SocketChannelController implements Connector
Connected session manager- Author:
- dennis
-
-
Field Summary
Fields Modifier and Type Field Description protected Protocolprotocolprotected MemcachedSessionComparatorsessionComparatorprotected MemcachedSessionLocatorsessionLocatorprotected ConcurrentHashMap<InetSocketAddress,Queue<Session>>sessionMap-
Fields inherited from class com.google.code.yanf4j.nio.impl.SocketChannelController
soLingerOn
-
Fields inherited from class com.google.code.yanf4j.nio.impl.NioController
selectorManager, selectorPoolSize
-
Fields inherited from class com.google.code.yanf4j.core.impl.AbstractController
codecFactory, configuration, dispatchMessageDispatcher, dispatchMessageThreadCount, handler, handleReadWriteConcurrently, localSocketAddress, log, readEventDispatcher, readThreadCount, sessionSet, sessionTimeout, socketOptions, soTimeout, started, stateListeners, statistics, statisticsInterval, writeEventDispatcher, writeThreadCount
-
-
Constructor Summary
Constructors Constructor Description MemcachedConnector(Configuration configuration, MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations)
-
Method Summary
-
Methods inherited from class com.google.code.yanf4j.nio.impl.SocketChannelController
configureSocketChannel, dispatchReadEvent, dispatchWriteEvent, setSoLinger
-
Methods inherited from class com.google.code.yanf4j.nio.impl.NioController
bind, buildSessionConfig, closeSelectionKey, getSelectorManager, getSelectorPoolSize, initialSelectorManager, onRead, onWrite, setSelectorPoolSize, start0, stop0
-
Methods inherited from class com.google.code.yanf4j.core.impl.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, unregisterSession
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.rubyeye.xmemcached.networking.Connector
setSocketOptions
-
Methods inherited from interface com.google.code.yanf4j.core.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, stop
-
Methods inherited from interface com.google.code.yanf4j.nio.SelectionKeyHandler
onAccept
-
-
-
-
Field Detail
-
protocol
protected Protocol protocol
-
sessionLocator
protected MemcachedSessionLocator sessionLocator
-
sessionComparator
protected MemcachedSessionComparator sessionComparator
-
sessionMap
protected final ConcurrentHashMap<InetSocketAddress,Queue<Session>> sessionMap
-
-
Constructor Detail
-
MemcachedConnector
public MemcachedConnector(Configuration configuration, MemcachedSessionLocator locator, MemcachedSessionComparator comparator, BufferAllocator allocator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations)
-
-
Method Detail
-
shuttingDown
public void shuttingDown()
-
setSessionLocator
public void setSessionLocator(MemcachedSessionLocator sessionLocator)
- Specified by:
setSessionLocatorin interfaceConnector
-
setSessionComparator
public void setSessionComparator(MemcachedSessionComparator sessionComparator)
- Specified by:
setSessionComparatorin interfaceConnector
-
setEnableHealSession
public void setEnableHealSession(boolean enableHealSession)
- Specified by:
setEnableHealSessionin interfaceConnector
-
getReconnectRequestQueue
public Queue<ReconnectRequest> getReconnectRequestQueue()
- Specified by:
getReconnectRequestQueuein interfaceConnector
-
getSessionSet
public Set<Session> 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
public Protocol getProtocol()
-
addSession
public void addSession(Session session)
-
getSessionListBySocketAddress
public List<Session> getSessionListBySocketAddress(InetSocketAddress inetSocketAddress)
-
removeReconnectRequest
public void removeReconnectRequest(InetSocketAddress inetSocketAddress)
- Specified by:
removeReconnectRequestin interfaceConnector
-
updateSessions
public final void updateSessions()
- Specified by:
updateSessionsin interfaceConnector
-
removeSession
public void removeSession(Session session)
- Specified by:
removeSessionin interfaceConnector
-
doStart
protected void doStart() throws IOExceptionDescription copied from class:NioControllerInner startup- Specified by:
doStartin classNioController- Throws:
IOException
-
onConnect
public void onConnect(SelectionKey key) throws IOException
- Specified by:
onConnectin interfaceSelectionKeyHandler- Overrides:
onConnectin classAbstractController- Throws:
IOException
-
createSession
protected MemcachedTCPSession createSession(SocketChannel socketChannel, InetSocketAddressWrapper wrapper)
-
addToWatingQueue
public void addToWatingQueue(ReconnectRequest request)
- Specified by:
addToWatingQueuein interfaceConnector
-
connect
public Future<Boolean> connect(InetSocketAddressWrapper addressWrapper)
-
closeChannel
public void closeChannel(Selector selector) throws IOException
- Specified by:
closeChannelin interfaceSelectionKeyHandler- Throws:
IOException
-
send
public Session send(Command msg) throws MemcachedException
- Specified by:
sendin interfaceConnector- Throws:
MemcachedException
-
getStandbySessionListByMainNodeAddr
public List<Session> getStandbySessionListByMainNodeAddr(InetSocketAddress addr)
Returns main node's standby session list.- Specified by:
getStandbySessionListByMainNodeAddrin interfaceConnector- Parameters:
addr-- Returns:
-
getSessionByAddress
public final Queue<Session> getSessionByAddress(InetSocketAddress addr)
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
public FlowControl getNoReplyOpsFlowControl()
Description copied from interface:ConnectorReturns the noreply operations flow control manager.- Specified by:
getNoReplyOpsFlowControlin interfaceConnector- Returns:
-
buildSession
protected NioSession buildSession(SocketChannel sc)
- Overrides:
buildSessionin classSocketChannelController
-
buildQueue
protected Queue<WriteMessage> buildQueue()
Build write queue for session- Overrides:
buildQueuein classAbstractController- Returns:
-
getBufferAllocator
public BufferAllocator 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
public void setBufferAllocator(BufferAllocator allocator)
- Specified by:
setBufferAllocatorin interfaceConnector
-
getServerAddresses
public Collection<InetSocketAddress> getServerAddresses()
-
-