|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.spy.memcached.compat.SpyObject net.spy.memcached.protocol.TCPMemcachedNodeImpl
public abstract class TCPMemcachedNodeImpl
Represents a node with the memcached cluster, along with buffering and operation queues.
Field Summary | |
---|---|
protected Operation |
optimizedOp
|
protected BlockingQueue<Operation> |
writeQ
|
Constructor Summary | |
---|---|
TCPMemcachedNodeImpl(SocketAddress sa,
SocketChannel c,
int bufSize,
BlockingQueue<Operation> rq,
BlockingQueue<Operation> wq,
BlockingQueue<Operation> iq)
|
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 shouldOptimize)
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. |
protected abstract void |
optimize()
|
void |
reconnecting()
Notify this node that it will be reconnecting. |
void |
registerChannel(SocketChannel ch,
SelectionKey skey)
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. |
String |
toString()
|
void |
transitionWriteItem()
Transition the current write item into a read state. |
int |
writeSome()
Write some bytes and return the number of bytes written. |
Methods inherited from class net.spy.memcached.compat.SpyObject |
---|
getLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final BlockingQueue<Operation> writeQ
protected Operation optimizedOp
Constructor Detail |
---|
public TCPMemcachedNodeImpl(SocketAddress sa, SocketChannel c, int bufSize, BlockingQueue<Operation> rq, BlockingQueue<Operation> wq, BlockingQueue<Operation> iq)
Method Detail |
---|
public final void copyInputQueue()
MemcachedNode
copyInputQueue
in interface MemcachedNode
public Collection<Operation> destroyInputQueue()
MemcachedNode
destroyInputQueue
in interface MemcachedNode
public final void setupResend()
MemcachedNode
setupResend
in interface MemcachedNode
public final void fillWriteBuffer(boolean shouldOptimize)
MemcachedNode
fillWriteBuffer
in interface MemcachedNode
shouldOptimize
- if true, combine sequential gets into a single
multi-key getpublic final void transitionWriteItem()
MemcachedNode
transitionWriteItem
in interface MemcachedNode
protected abstract void optimize()
public final Operation getCurrentReadOp()
MemcachedNode
getCurrentReadOp
in interface MemcachedNode
public final Operation removeCurrentReadOp()
MemcachedNode
removeCurrentReadOp
in interface MemcachedNode
public final Operation getCurrentWriteOp()
MemcachedNode
getCurrentWriteOp
in interface MemcachedNode
public final Operation removeCurrentWriteOp()
MemcachedNode
removeCurrentWriteOp
in interface MemcachedNode
public final boolean hasReadOp()
MemcachedNode
hasReadOp
in interface MemcachedNode
public final boolean hasWriteOp()
MemcachedNode
hasWriteOp
in interface MemcachedNode
public final void addOp(Operation op)
MemcachedNode
addOp
in interface MemcachedNode
public final int getSelectionOps()
MemcachedNode
getSelectionOps
in interface MemcachedNode
public final ByteBuffer getRbuf()
MemcachedNode
getRbuf
in interface MemcachedNode
public final ByteBuffer getWbuf()
MemcachedNode
getWbuf
in interface MemcachedNode
public final SocketAddress getSocketAddress()
MemcachedNode
getSocketAddress
in interface MemcachedNode
public final boolean isActive()
MemcachedNode
active.i.e. is is currently connected and expected to be able to process requests
isActive
in interface MemcachedNode
public final void reconnecting()
MemcachedNode
reconnecting
in interface MemcachedNode
public final void connected()
MemcachedNode
connected
in interface MemcachedNode
public final int getReconnectCount()
MemcachedNode
getReconnectCount
in interface MemcachedNode
public final String toString()
toString
in class Object
public final void registerChannel(SocketChannel ch, SelectionKey skey)
MemcachedNode
registerChannel
in interface MemcachedNode
public final void setChannel(SocketChannel to)
MemcachedNode
setChannel
in interface MemcachedNode
public final SocketChannel getChannel()
MemcachedNode
getChannel
in interface MemcachedNode
public final void setSk(SelectionKey to)
MemcachedNode
setSk
in interface MemcachedNode
public final SelectionKey getSk()
MemcachedNode
getSk
in interface MemcachedNode
public final int getBytesRemainingToWrite()
MemcachedNode
getBytesRemainingToWrite
in interface MemcachedNode
public final int writeSome() throws IOException
MemcachedNode
writeSome
in interface MemcachedNode
IOException
- if there's a problem writingpublic final void fixupOps()
MemcachedNode
fixupOps
in interface MemcachedNode
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |