net.spy.memcached
Interface MemcachedNode

All Known Implementing Classes:
AsciiMemcachedNodeImpl, BinaryMemcachedNodeImpl, TCPMemcachedNodeImpl

public interface MemcachedNode

Interface defining a connection to a memcached server.


Method Summary
 void addOp(Operation op)
          Add an operation to the queue.
 void connected()
          Notify this node that it has reconnected.
 void copyInputQueue()
          Move all of the operations delivered via addOperation into the internal write queue.
 Collection<Operation> destroyInputQueue()
          Extract all queued items for this node destructively.
 void fillWriteBuffer(boolean optimizeGets)
          Fill the write buffer with data from the next operations in the queue.
 void fixupOps()
          Fix up the selection ops on the selection key.
 int getBytesRemainingToWrite()
          Get the number of bytes remaining to write.
 SocketChannel getChannel()
          Get the SocketChannel for this connection.
 Operation getCurrentReadOp()
          Get the operation at the top of the queue that is requiring input.
 Operation getCurrentWriteOp()
          Get the operation at the top of the queue that has information available to write.
 ByteBuffer getRbuf()
          Get the buffer used for reading data from this node.
 int getReconnectCount()
          Get the current reconnect count.
 int getSelectionOps()
          Compute the appropriate selection operations for the channel this MemcachedNode holds to the server.
 SelectionKey getSk()
          Get the selection key from this node.
 SocketAddress getSocketAddress()
          Get the SocketAddress of the server to which this node is connected.
 ByteBuffer getWbuf()
          Get the buffer used for writing data to this node.
 boolean hasReadOp()
          True if an operation is available to read.
 boolean hasWriteOp()
          True if an operation is available to write.
 boolean isActive()
          True if this node is active. i.e.
 void reconnecting()
          Notify this node that it will be reconnecting.
 void registerChannel(SocketChannel ch, SelectionKey selectionKey)
          Register a channel with this node.
 Operation removeCurrentReadOp()
          Remove the operation at the top of the queue that is requiring input.
 Operation removeCurrentWriteOp()
          Remove the operation at the top of the queue that has information available to write.
 void setChannel(SocketChannel to)
          Set the SocketChannel this node uses.
 void setSk(SelectionKey to)
          Set the selection key for this node.
 void setupResend()
          Clear the queue of currently processing operations by either cancelling them or setting them up to be reapplied after a reconnect.
 void transitionWriteItem()
          Transition the current write item into a read state.
 int writeSome()
          Write some bytes and return the number of bytes written.
 

Method Detail

copyInputQueue

void copyInputQueue()
Move all of the operations delivered via addOperation into the internal write queue.


destroyInputQueue

Collection<Operation> destroyInputQueue()
Extract all queued items for this node destructively. This is useful for redistributing items.


setupResend

void setupResend()
Clear the queue of currently processing operations by either cancelling them or setting them up to be reapplied after a reconnect.


fillWriteBuffer

void fillWriteBuffer(boolean optimizeGets)
Fill the write buffer with data from the next operations in the queue.

Parameters:
optimizeGets - if true, combine sequential gets into a single multi-key get

transitionWriteItem

void transitionWriteItem()
Transition the current write item into a read state.


getCurrentReadOp

Operation getCurrentReadOp()
Get the operation at the top of the queue that is requiring input.


removeCurrentReadOp

Operation removeCurrentReadOp()
Remove the operation at the top of the queue that is requiring input.


getCurrentWriteOp

Operation getCurrentWriteOp()
Get the operation at the top of the queue that has information available to write.


removeCurrentWriteOp

Operation removeCurrentWriteOp()
Remove the operation at the top of the queue that has information available to write.


hasReadOp

boolean hasReadOp()
True if an operation is available to read.


hasWriteOp

boolean hasWriteOp()
True if an operation is available to write.


addOp

void addOp(Operation op)
Add an operation to the queue.


getSelectionOps

int getSelectionOps()
Compute the appropriate selection operations for the channel this MemcachedNode holds to the server.


getRbuf

ByteBuffer getRbuf()
Get the buffer used for reading data from this node.


getWbuf

ByteBuffer getWbuf()
Get the buffer used for writing data to this node.


getSocketAddress

SocketAddress getSocketAddress()
Get the SocketAddress of the server to which this node is connected.


isActive

boolean isActive()
True if this node is active. i.e. is is currently connected and expected to be able to process requests


reconnecting

void reconnecting()
Notify this node that it will be reconnecting.


connected

void connected()
Notify this node that it has reconnected.


getReconnectCount

int getReconnectCount()
Get the current reconnect count.


registerChannel

void registerChannel(SocketChannel ch,
                     SelectionKey selectionKey)
Register a channel with this node.


setChannel

void setChannel(SocketChannel to)
Set the SocketChannel this node uses.


getChannel

SocketChannel getChannel()
Get the SocketChannel for this connection.


setSk

void setSk(SelectionKey to)
Set the selection key for this node.


getSk

SelectionKey getSk()
Get the selection key from this node.


getBytesRemainingToWrite

int getBytesRemainingToWrite()
Get the number of bytes remaining to write.


writeSome

int writeSome()
              throws IOException
Write some bytes and return the number of bytes written.

Returns:
the number of bytes written
Throws:
IOException - if there's a problem writing

fixupOps

void fixupOps()
Fix up the selection ops on the selection key.