net.spy.memcached
Class MemcachedConnection

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.memcached.MemcachedConnection

public final class MemcachedConnection
extends net.spy.SpyObject

Connection to a cluster of memcached servers.


Constructor Summary
MemcachedConnection(int bufSize, ConnectionFactory f, java.util.List<java.net.InetSocketAddress> a)
          Construct a memcached connection.
 
Method Summary
 void addOperation(MemcachedNode node, Operation o)
           
 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.
 void handleIO()
          MemcachedClient calls this method to handle IO over the connections.
 void setGetOptimization(boolean to)
          Enable or disable get optimization.
 void shutdown()
          Shut down all of the connections.
 java.lang.String toString()
           
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemcachedConnection

public MemcachedConnection(int bufSize,
                           ConnectionFactory f,
                           java.util.List<java.net.InetSocketAddress> a)
                    throws java.io.IOException
Construct a memcached connection.

Parameters:
bufSize - the size of the buffer used for reading from the server
f - the factory that will provide an operation queue
a - the addresses of the servers to connect to
Throws:
java.io.IOException - if a connection attempt fails early
Method Detail

setGetOptimization

public void setGetOptimization(boolean to)
Enable or disable get optimization. When enabled (default), multiple sequential gets are collapsed into one.


handleIO

public void handleIO()
              throws java.io.IOException
MemcachedClient calls this method to handle IO over the connections.

Throws:
java.io.IOException

addOperation

public void addOperation(java.lang.String key,
                         Operation o)
Add an operation to the given connection.

Parameters:
which - the connection offset
o - the operation

addOperation

public void addOperation(MemcachedNode node,
                         Operation o)

addOperations

public void addOperations(java.util.Map<MemcachedNode,Operation> ops)

broadcastOperation

public java.util.concurrent.CountDownLatch broadcastOperation(BroadcastOpFactory of)
Broadcast an operation to all nodes.


shutdown

public void shutdown()
              throws java.io.IOException
Shut down all of the connections.

Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object