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,
long authWaitTime,
ConnectionFactory fact) |
| 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.nio.ByteBuffer |
decryptNextTLSDataRecord(java.nio.ByteBuffer rbuf)
Convert the encrypted data record that received from this node to plain text data.
|
java.util.Collection<Operation> |
destroyInputQueue()
Extract all queued items for this node destructively.
|
boolean |
doTlsHandshake(long timeoutInMillis)
Do handshake for connecting to this node when TLS enabled.
|
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.
|
MemcachedConnection |
getConnection() |
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.
|
NodeEndPoint |
getNodeEndPoint()
Get NodeEndPoint
|
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 |
setConnection(MemcachedConnection connection) |
void |
setContinuousTimeout(boolean timedOut)
Count 'time out' exceptions to drop connections that fail perpetually.
|
void |
setNodeEndPoint(NodeEndPoint nodeEndPoint)
Set NodeEndPoint
|
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,
long authWaitTime,
ConnectionFactory fact)
public final void copyInputQueue()
MemcachedNodecopyInputQueue in interface MemcachedNodepublic java.util.Collection<Operation> destroyInputQueue()
MemcachedNodedestroyInputQueue in interface MemcachedNodepublic final void setupResend()
MemcachedNodesetupResend in interface MemcachedNodepublic final void fillWriteBuffer(boolean shouldOptimize)
throws java.io.IOException
MemcachedNodefillWriteBuffer in interface MemcachedNodeshouldOptimize - if true, combine sequential gets into a single
multi-key getjava.io.IOExceptionpublic final void transitionWriteItem()
MemcachedNodetransitionWriteItem in interface MemcachedNodeprotected abstract void optimize()
public final Operation getCurrentReadOp()
MemcachedNodegetCurrentReadOp in interface MemcachedNodepublic final Operation removeCurrentReadOp()
MemcachedNoderemoveCurrentReadOp in interface MemcachedNodepublic final Operation getCurrentWriteOp()
MemcachedNodegetCurrentWriteOp in interface MemcachedNodepublic final Operation removeCurrentWriteOp()
MemcachedNoderemoveCurrentWriteOp in interface MemcachedNodepublic final boolean hasReadOp()
MemcachedNodehasReadOp in interface MemcachedNodepublic final boolean hasWriteOp()
MemcachedNodehasWriteOp in interface MemcachedNodepublic final void addOp(Operation op)
MemcachedNodeaddOp in interface MemcachedNodepublic final void insertOp(Operation op)
MemcachedNodeinsertOp in interface MemcachedNodepublic final int getSelectionOps()
MemcachedNodegetSelectionOps in interface MemcachedNodepublic final java.nio.ByteBuffer getRbuf()
MemcachedNodegetRbuf in interface MemcachedNodepublic final java.nio.ByteBuffer getWbuf()
MemcachedNodegetWbuf in interface MemcachedNodepublic final boolean doTlsHandshake(long timeoutInMillis)
throws java.io.IOException
MemcachedNodedoTlsHandshake in interface MemcachedNodejava.io.IOExceptionpublic final java.nio.ByteBuffer decryptNextTLSDataRecord(java.nio.ByteBuffer rbuf)
throws java.io.IOException
MemcachedNodedecryptNextTLSDataRecord in interface MemcachedNodejava.io.IOExceptionpublic final java.net.SocketAddress getSocketAddress()
MemcachedNodegetSocketAddress in interface MemcachedNodepublic final NodeEndPoint getNodeEndPoint()
MemcachedNodegetNodeEndPoint in interface MemcachedNodepublic void setNodeEndPoint(NodeEndPoint nodeEndPoint)
MemcachedNodesetNodeEndPoint in interface MemcachedNodenodeEndPoint - public final boolean isActive()
MemcachedNodeactive.i.e. is is currently connected and expected to be able to process requests
isActive in interface MemcachedNodepublic boolean isAuthenticated()
MemcachedNodeauthenticated.
isAuthenticated in interface MemcachedNodepublic final void reconnecting()
MemcachedNodereconnecting in interface MemcachedNodepublic final void connected()
MemcachedNodeconnected in interface MemcachedNodepublic final int getReconnectCount()
MemcachedNodegetReconnectCount in interface MemcachedNodepublic final java.lang.String toString()
toString in class java.lang.Objectpublic final void registerChannel(java.nio.channels.SocketChannel ch,
java.nio.channels.SelectionKey skey)
MemcachedNoderegisterChannel in interface MemcachedNodepublic final void setChannel(java.nio.channels.SocketChannel to)
MemcachedNodesetChannel in interface MemcachedNodepublic final java.nio.channels.SocketChannel getChannel()
MemcachedNodegetChannel in interface MemcachedNodepublic final void setSk(java.nio.channels.SelectionKey to)
MemcachedNodesetSk in interface MemcachedNodepublic final java.nio.channels.SelectionKey getSk()
MemcachedNodegetSk in interface MemcachedNodepublic final int getBytesRemainingToWrite()
MemcachedNodegetBytesRemainingToWrite in interface MemcachedNodepublic final int writeSome()
throws java.io.IOException
MemcachedNodewriteSome in interface MemcachedNodejava.io.IOException - if there's a problem writingpublic void setContinuousTimeout(boolean timedOut)
MemcachedNodesetContinuousTimeout in interface MemcachedNodepublic int getContinuousTimeout()
getContinuousTimeout in interface MemcachedNodepublic final void fixupOps()
MemcachedNodefixupOps in interface MemcachedNodepublic final void authComplete()
MemcachedNodeauthComplete in interface MemcachedNodepublic final void setupForAuth()
MemcachedNodesetupForAuth in interface MemcachedNodepublic long lastReadDelta()
lastReadDelta in interface MemcachedNodepublic void completedRead()
completedRead in interface MemcachedNodepublic MemcachedConnection getConnection()
getConnection in interface MemcachedNodepublic void setConnection(MemcachedConnection connection)
setConnection in interface MemcachedNodeCopyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.