public class MemcachedConnection extends SpyThread
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.ConcurrentLinkedQueue<MemcachedNode> |
addedQueue |
protected FailureMode |
failureMode |
protected NodeLocator |
locator |
protected java.util.concurrent.ConcurrentLinkedQueue<MemcachedNode> |
nodesToShutdown |
protected boolean |
running |
protected java.nio.channels.Selector |
selector |
protected boolean |
shutDown |
| Constructor and Description |
|---|
MemcachedConnection(int bufSize,
ConnectionFactory f,
java.util.List<java.net.InetSocketAddress> a,
java.util.Collection<ConnectionObserver> obs,
FailureMode fm,
OperationFactory opfactory)
Construct a memcached connection.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addObserver(ConnectionObserver obs)
Add a connection observer.
|
protected void |
addOperation(MemcachedNode node,
Operation o) |
protected void |
addOperation(java.lang.String key,
Operation o)
Add an operation to the given connection.
|
void |
addOperations(java.util.Map<MemcachedNode,Operation> ops) |
java.util.concurrent.CountDownLatch |
broadcastOperation(BroadcastOpFactory of)
Broadcast an operation to all nodes.
|
java.util.concurrent.CountDownLatch |
broadcastOperation(BroadcastOpFactory of,
java.util.Collection<MemcachedNode> nodes)
Broadcast an operation to a specific collection of nodes.
|
protected void |
checkState()
Check to see if this connection is shutting down.
|
java.lang.String |
connectionsStatus()
Get information about connections and their active status.
|
protected java.util.List<MemcachedNode> |
createConnections(java.util.Collection<java.net.InetSocketAddress> a) |
void |
enqueueOperation(java.lang.String key,
Operation o) |
NodeLocator |
getLocator()
Get the node locator used by this connection.
|
void |
handleIO()
MemcachedClient calls this method to handle IO over the connections.
|
void |
insertOperation(MemcachedNode node,
Operation o) |
static void |
opSucceeded(Operation op)
helper method: reset timeout counter.
|
static void |
opTimedOut(Operation op)
helper method: increase timeout count on node attached to this op.
|
protected void |
queueReconnect(MemcachedNode qa) |
boolean |
removeObserver(ConnectionObserver obs)
Remove a connection observer.
|
void |
run()
Infinitely loop processing IO.
|
void |
shutdown()
Shut down all of the connections.
|
java.lang.String |
toString() |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yieldprotected volatile boolean shutDown
protected java.nio.channels.Selector selector
protected final NodeLocator locator
protected final FailureMode failureMode
protected final java.util.concurrent.ConcurrentLinkedQueue<MemcachedNode> addedQueue
protected volatile boolean running
protected final java.util.concurrent.ConcurrentLinkedQueue<MemcachedNode> nodesToShutdown
public MemcachedConnection(int bufSize,
ConnectionFactory f,
java.util.List<java.net.InetSocketAddress> a,
java.util.Collection<ConnectionObserver> obs,
FailureMode fm,
OperationFactory opfactory)
throws java.io.IOException
bufSize - the size of the buffer used for reading from the serverf - the factory that will provide an operation queuea - the addresses of the servers to connect tojava.io.IOException - if a connection attempt fails earlyprotected java.util.List<MemcachedNode> createConnections(java.util.Collection<java.net.InetSocketAddress> a) throws java.io.IOException
java.io.IOExceptionpublic void handleIO()
throws java.io.IOException
java.io.IOExceptionpublic boolean addObserver(ConnectionObserver obs)
public boolean removeObserver(ConnectionObserver obs)
protected void queueReconnect(MemcachedNode qa)
public NodeLocator getLocator()
public void enqueueOperation(java.lang.String key,
Operation o)
protected void addOperation(java.lang.String key,
Operation o)
key - the key the operation is operating upono - the operationpublic void insertOperation(MemcachedNode node, Operation o)
protected void addOperation(MemcachedNode node, Operation o)
public void addOperations(java.util.Map<MemcachedNode,Operation> ops)
public java.util.concurrent.CountDownLatch broadcastOperation(BroadcastOpFactory of)
public java.util.concurrent.CountDownLatch broadcastOperation(BroadcastOpFactory of, java.util.Collection<MemcachedNode> nodes)
public void shutdown()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Threadpublic java.lang.String connectionsStatus()
public static void opTimedOut(Operation op)
op - public static void opSucceeded(Operation op)
op - protected void checkState()
public void run()
run in interface java.lang.Runnablerun in class java.lang.ThreadCopyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.