MemcachedConnection Class Reference

Inherits net::spy::SpyObject.

Collaboration diagram for MemcachedConnection:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void addOperation (final MemcachedNode node, final Operation o)
void addOperation (final String key, final Operation o)
void addOperations (final Map< MemcachedNode, Operation > ops)
CountDownLatch broadcastOperation (final BroadcastOpFactory of)
void handleIO () throws IOException
 MemcachedConnection (int bufSize, ConnectionFactory f, List< InetSocketAddress > a) throws IOException
void setGetOptimization (boolean to)
void shutdown () throws IOException
String toString ()

Package Functions

NodeLocator getLocator ()

Static Package Functions

static String dbgBuffer (ByteBuffer b, int size)

Private Member Functions

void attemptReconnects () throws IOException
void handleInputQueue ()
void handleIO (SelectionKey sk)
void handleReads (SelectionKey sk, MemcachedNode qa) throws IOException
void handleWrites (SelectionKey sk, MemcachedNode qa) throws IOException
void queueReconnect (MemcachedNode qa)
boolean selectorsMakeSense ()

Private Attributes

final ConcurrentLinkedQueue
< MemcachedNode
addedQueue
int emptySelects = 0
final NodeLocator locator
boolean optimizeGets = true
final SortedMap< Long,
MemcachedNode
reconnectQueue
Selector selector = null
volatile boolean shutDown = false

Static Private Attributes

static final int DOUBLE_CHECK_EMPTY = 256
static final int EXCESSIVE_EMPTY = 0x1000000
static final long MAX_DELAY = 30000


Detailed Description

Connection to a cluster of memcached servers.

Constructor & Destructor Documentation

MemcachedConnection ( int  bufSize,
ConnectionFactory  f,
List< InetSocketAddress >  a 
) throws 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
Exceptions:
IOException if a connection attempt fails early


Member Function Documentation

void addOperation ( final MemcachedNode  node,
final Operation  o 
)

void addOperation ( final String  key,
final Operation  o 
)

Add an operation to the given connection.

Parameters:
which the connection offset
o the operation

void addOperations ( final Map< MemcachedNode, Operation ops  ) 

void attemptReconnects (  )  throws IOException [private]

CountDownLatch broadcastOperation ( final BroadcastOpFactory  of  ) 

Broadcast an operation to all nodes.

static String dbgBuffer ( ByteBuffer  b,
int  size 
) [static, package]

NodeLocator getLocator (  )  [package]

Get the node locator used by this connection.

void handleInputQueue (  )  [private]

void handleIO ( SelectionKey  sk  )  [private]

void handleIO (  )  throws IOException

MemcachedClient calls this method to handle IO over the connections.

void handleReads ( SelectionKey  sk,
MemcachedNode  qa 
) throws IOException [private]

void handleWrites ( SelectionKey  sk,
MemcachedNode  qa 
) throws IOException [private]

void queueReconnect ( MemcachedNode  qa  )  [private]

boolean selectorsMakeSense (  )  [private]

void setGetOptimization ( boolean  to  ) 

Enable or disable get optimization.

When enabled (default), multiple sequential gets are collapsed into one.

void shutdown (  )  throws IOException

Shut down all of the connections.

String toString (  ) 


Member Data Documentation

final ConcurrentLinkedQueue<MemcachedNode> addedQueue [private]

final int DOUBLE_CHECK_EMPTY = 256 [static, private]

int emptySelects = 0 [private]

final int EXCESSIVE_EMPTY = 0x1000000 [static, private]

final NodeLocator locator [private]

final long MAX_DELAY = 30000 [static, private]

boolean optimizeGets = true [private]

final SortedMap<Long, MemcachedNode> reconnectQueue [private]

Selector selector = null [private]

volatile boolean shutDown = false [private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:37 2012 for Project Wonder by  doxygen 1.5.8