public abstract class TCPMemcachedNodeImpl extends SpyObject implements MemcachedNode
Modifier and Type | Field and Description |
---|---|
protected Operation |
optimizedOp |
protected java.util.concurrent.BlockingQueue<Operation> |
writeQ |
Constructor and Description |
---|
TCPMemcachedNodeImpl(java.net.SocketAddress sa,
java.nio.channels.SocketChannel c,
int bufSize,
java.util.concurrent.BlockingQueue<Operation> rq,
java.util.concurrent.BlockingQueue<Operation> wq,
java.util.concurrent.BlockingQueue<Operation> iq,
long opQueueMaxBlockTime,
boolean waitForAuth,
long dt) |
Modifier and Type | Method and Description |
---|---|
void |
addOp(Operation op)
Add an operation to the queue.
|
void |
authComplete()
Let the node know that auth is complete.
|
void |
completedRead()
Mark this node as having just completed a read.
|
void |
connected()
Notify this node that it has reconnected.
|
void |
copyInputQueue()
Move all of the operations delivered via addOperation into the internal
write queue.
|
java.util.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.
|
java.nio.channels.SocketChannel |
getChannel()
Get the SocketChannel for this connection.
|
int |
getContinuousTimeout() |
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.
|
java.nio.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.
|
java.nio.channels.SelectionKey |
getSk()
Get the selection key from this node.
|
java.net.SocketAddress |
getSocketAddress()
Get the SocketAddress of the server to which this node is connected.
|
java.nio.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.
|
void |
insertOp(Operation op)
Insert an operation to the beginning of the queue.
|
boolean |
isActive()
True if this node is
active.i.e. |
boolean |
isAuthenticated()
True if this node is
authenticated. |
long |
lastReadDelta()
Number of milliseconds since the last read of this node completed.
|
protected abstract void |
optimize() |
void |
reconnecting()
Notify this node that it will be reconnecting.
|
void |
registerChannel(java.nio.channels.SocketChannel ch,
java.nio.channels.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(java.nio.channels.SocketChannel to)
Set the SocketChannel this node uses.
|
void |
setContinuousTimeout(boolean timedOut)
Count 'time out' exceptions to drop connections that fail perpetually.
|
void |
setSk(java.nio.channels.SelectionKey to)
Set the selection key for this node.
|
void |
setupForAuth()
Tell a node to set up for authentication.
|
void |
setupResend()
Clear the queue of currently processing operations by either cancelling
them or setting them up to be reapplied after a reconnect.
|
java.lang.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.
|
protected final java.util.concurrent.BlockingQueue<Operation> writeQ
protected Operation optimizedOp
public TCPMemcachedNodeImpl(java.net.SocketAddress sa, java.nio.channels.SocketChannel c, int bufSize, java.util.concurrent.BlockingQueue<Operation> rq, java.util.concurrent.BlockingQueue<Operation> wq, java.util.concurrent.BlockingQueue<Operation> iq, long opQueueMaxBlockTime, boolean waitForAuth, long dt)
public final void copyInputQueue()
MemcachedNode
copyInputQueue
in interface MemcachedNode
public java.util.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 void insertOp(Operation op)
MemcachedNode
insertOp
in interface MemcachedNode
public final int getSelectionOps()
MemcachedNode
getSelectionOps
in interface MemcachedNode
public final java.nio.ByteBuffer getRbuf()
MemcachedNode
getRbuf
in interface MemcachedNode
public final java.nio.ByteBuffer getWbuf()
MemcachedNode
getWbuf
in interface MemcachedNode
public final java.net.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 boolean isAuthenticated()
MemcachedNode
authenticated.
isAuthenticated
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 java.lang.String toString()
toString
in class java.lang.Object
public final void registerChannel(java.nio.channels.SocketChannel ch, java.nio.channels.SelectionKey skey)
MemcachedNode
registerChannel
in interface MemcachedNode
public final void setChannel(java.nio.channels.SocketChannel to)
MemcachedNode
setChannel
in interface MemcachedNode
public final java.nio.channels.SocketChannel getChannel()
MemcachedNode
getChannel
in interface MemcachedNode
public final void setSk(java.nio.channels.SelectionKey to)
MemcachedNode
setSk
in interface MemcachedNode
public final java.nio.channels.SelectionKey getSk()
MemcachedNode
getSk
in interface MemcachedNode
public final int getBytesRemainingToWrite()
MemcachedNode
getBytesRemainingToWrite
in interface MemcachedNode
public final int writeSome() throws java.io.IOException
MemcachedNode
writeSome
in interface MemcachedNode
java.io.IOException
- if there's a problem writingpublic void setContinuousTimeout(boolean timedOut)
MemcachedNode
setContinuousTimeout
in interface MemcachedNode
public int getContinuousTimeout()
getContinuousTimeout
in interface MemcachedNode
public final void fixupOps()
MemcachedNode
fixupOps
in interface MemcachedNode
public final void authComplete()
MemcachedNode
authComplete
in interface MemcachedNode
public final void setupForAuth()
MemcachedNode
setupForAuth
in interface MemcachedNode
public long lastReadDelta()
lastReadDelta
in interface MemcachedNode
public void completedRead()
completedRead
in interface MemcachedNode
Copyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.