Package net.spy.memcached
Class MemcachedNodeROImpl
java.lang.Object
net.spy.memcached.MemcachedNodeROImpl
- All Implemented Interfaces:
MemcachedNode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an operation to the queue.voidLet the node know that auth is complete.voidNotify node of successful read.voidNotify this node that it has reconnected.voidMove all of the operations delivered via addOperation into the internal write queue.Convert the encrypted data record that received from this node to plain text data.Extract all queued items for this node destructively.booleandoTlsHandshake(long timeoutInMillis) Do handshake for connecting to this node when TLS enabled.voidfillWriteBuffer(boolean optimizeGets) Fill the write buffer with data from the next operations in the queue.voidfixupOps()Fix up the selection ops on the selection key.intGet the number of bytes remaining to write.Get the SocketChannel for this connection.intGet the operation at the top of the queue that is requiring input.Get the operation at the top of the queue that has information available to write.Get NodeEndPointgetRbuf()Get the buffer used for reading data from this node.intGet the current reconnect count.intCompute the appropriate selection operations for the channel this MemcachedNode holds to the server.getSk()Get the selection key from this node.Get the SocketAddress of the server to which this node is connected.getWbuf()Get the buffer used for writing data to this node.booleanTrue if an operation is available to read.booleanTrue if an operation is available to write.voidInsert an operation to the beginning of the queue.booleanisActive()True if this node isactive.
i.e.booleanTrue if this node isauthenticated.
longMilliseconds since last successful read.voidNotify this node that it will be reconnecting.voidregisterChannel(SocketChannel ch, SelectionKey selectionKey) Register a channel with this node.Remove the operation at the top of the queue that is requiring input.Remove the operation at the top of the queue that has information available to write.voidSet the SocketChannel this node uses.voidsetConnection(MemcachedConnection connection) voidsetContinuousTimeout(boolean isIncrease) Count 'time out' exceptions to drop connections that fail perpetually.voidsetNodeEndPoint(NodeEndPoint endPoint) Set NodeEndPointvoidsetSk(SelectionKey to) Set the selection key for this node.voidTell a node to set up for authentication.voidClear the queue of currently processing operations by either cancelling them or setting them up to be reapplied after a reconnect.toString()voidTransition the current write item into a read state.intWrite some bytes and return the number of bytes written.
-
Constructor Details
-
MemcachedNodeROImpl
-
-
Method Details
-
toString
-
addOp
Description copied from interface:MemcachedNodeAdd an operation to the queue. Authentication operations should never be added to the queue, but this is not checked.- Specified by:
addOpin interfaceMemcachedNode
-
insertOp
Description copied from interface:MemcachedNodeInsert an operation to the beginning of the queue. This method is meant to be invoked rarely.- Specified by:
insertOpin interfaceMemcachedNode
-
connected
public void connected()Description copied from interface:MemcachedNodeNotify this node that it has reconnected.- Specified by:
connectedin interfaceMemcachedNode
-
copyInputQueue
public void copyInputQueue()Description copied from interface:MemcachedNodeMove all of the operations delivered via addOperation into the internal write queue.- Specified by:
copyInputQueuein interfaceMemcachedNode
-
fillWriteBuffer
Description copied from interface:MemcachedNodeFill the write buffer with data from the next operations in the queue.- Specified by:
fillWriteBufferin interfaceMemcachedNode- Parameters:
optimizeGets- if true, combine sequential gets into a single multi-key get- Throws:
IOException
-
fixupOps
public void fixupOps()Description copied from interface:MemcachedNodeFix up the selection ops on the selection key.- Specified by:
fixupOpsin interfaceMemcachedNode
-
getBytesRemainingToWrite
public int getBytesRemainingToWrite()Description copied from interface:MemcachedNodeGet the number of bytes remaining to write.- Specified by:
getBytesRemainingToWritein interfaceMemcachedNode
-
getChannel
Description copied from interface:MemcachedNodeGet the SocketChannel for this connection.- Specified by:
getChannelin interfaceMemcachedNode
-
getCurrentReadOp
Description copied from interface:MemcachedNodeGet the operation at the top of the queue that is requiring input.- Specified by:
getCurrentReadOpin interfaceMemcachedNode
-
getCurrentWriteOp
Description copied from interface:MemcachedNodeGet the operation at the top of the queue that has information available to write.- Specified by:
getCurrentWriteOpin interfaceMemcachedNode
-
getRbuf
Description copied from interface:MemcachedNodeGet the buffer used for reading data from this node.- Specified by:
getRbufin interfaceMemcachedNode
-
getReconnectCount
public int getReconnectCount()Description copied from interface:MemcachedNodeGet the current reconnect count.- Specified by:
getReconnectCountin interfaceMemcachedNode
-
getSelectionOps
public int getSelectionOps()Description copied from interface:MemcachedNodeCompute the appropriate selection operations for the channel this MemcachedNode holds to the server.- Specified by:
getSelectionOpsin interfaceMemcachedNode
-
getSk
Description copied from interface:MemcachedNodeGet the selection key from this node.- Specified by:
getSkin interfaceMemcachedNode
-
getSocketAddress
Description copied from interface:MemcachedNodeGet the SocketAddress of the server to which this node is connected.- Specified by:
getSocketAddressin interfaceMemcachedNode
-
getNodeEndPoint
Description copied from interface:MemcachedNodeGet NodeEndPoint- Specified by:
getNodeEndPointin interfaceMemcachedNode- Returns:
-
setNodeEndPoint
Description copied from interface:MemcachedNodeSet NodeEndPoint- Specified by:
setNodeEndPointin interfaceMemcachedNode
-
doTlsHandshake
Description copied from interface:MemcachedNodeDo handshake for connecting to this node when TLS enabled.- Specified by:
doTlsHandshakein interfaceMemcachedNode- Returns:
- true if handshake is successful, false if handshake is unsuccessful.
- Throws:
IOException
-
decryptNextTLSDataRecord
Description copied from interface:MemcachedNodeConvert the encrypted data record that received from this node to plain text data.- Specified by:
decryptNextTLSDataRecordin interfaceMemcachedNode- Returns:
- buffer contains plain text data.
- Throws:
IOException
-
getWbuf
Description copied from interface:MemcachedNodeGet the buffer used for writing data to this node.- Specified by:
getWbufin interfaceMemcachedNode
-
hasReadOp
public boolean hasReadOp()Description copied from interface:MemcachedNodeTrue if an operation is available to read.- Specified by:
hasReadOpin interfaceMemcachedNode
-
hasWriteOp
public boolean hasWriteOp()Description copied from interface:MemcachedNodeTrue if an operation is available to write.- Specified by:
hasWriteOpin interfaceMemcachedNode
-
isActive
public boolean isActive()Description copied from interface:MemcachedNodeTrue if this node isactive.
i.e. is is currently connected and expected to be able to process requests- Specified by:
isActivein interfaceMemcachedNode
-
reconnecting
public void reconnecting()Description copied from interface:MemcachedNodeNotify this node that it will be reconnecting.- Specified by:
reconnectingin interfaceMemcachedNode
-
registerChannel
Description copied from interface:MemcachedNodeRegister a channel with this node.- Specified by:
registerChannelin interfaceMemcachedNode
-
removeCurrentReadOp
Description copied from interface:MemcachedNodeRemove the operation at the top of the queue that is requiring input.- Specified by:
removeCurrentReadOpin interfaceMemcachedNode
-
removeCurrentWriteOp
Description copied from interface:MemcachedNodeRemove the operation at the top of the queue that has information available to write.- Specified by:
removeCurrentWriteOpin interfaceMemcachedNode
-
setChannel
Description copied from interface:MemcachedNodeSet the SocketChannel this node uses.- Specified by:
setChannelin interfaceMemcachedNode
-
setSk
Description copied from interface:MemcachedNodeSet the selection key for this node.- Specified by:
setSkin interfaceMemcachedNode
-
setupResend
public void setupResend()Description copied from interface:MemcachedNodeClear the queue of currently processing operations by either cancelling them or setting them up to be reapplied after a reconnect.- Specified by:
setupResendin interfaceMemcachedNode
-
transitionWriteItem
public void transitionWriteItem()Description copied from interface:MemcachedNodeTransition the current write item into a read state.- Specified by:
transitionWriteItemin interfaceMemcachedNode
-
writeSome
Description copied from interface:MemcachedNodeWrite some bytes and return the number of bytes written.- Specified by:
writeSomein interfaceMemcachedNode- Returns:
- the number of bytes written
- Throws:
IOException- if there's a problem writing
-
destroyInputQueue
Description copied from interface:MemcachedNodeExtract all queued items for this node destructively. This is useful for redistributing items.- Specified by:
destroyInputQueuein interfaceMemcachedNode
-
authComplete
public void authComplete()Description copied from interface:MemcachedNodeLet the node know that auth is complete. Typically this would mean the node can start processing and accept new operations to its input queue.- Specified by:
authCompletein interfaceMemcachedNode
-
setupForAuth
public void setupForAuth()Description copied from interface:MemcachedNodeTell a node to set up for authentication. Typically this would mean blocking additions to the queue. In a reconnect situation this may mean putting any queued operations on hold to get to an auth complete state.- Specified by:
setupForAuthin interfaceMemcachedNode
-
getContinuousTimeout
public int getContinuousTimeout()- Specified by:
getContinuousTimeoutin interfaceMemcachedNode
-
setContinuousTimeout
public void setContinuousTimeout(boolean isIncrease) Description copied from interface:MemcachedNodeCount 'time out' exceptions to drop connections that fail perpetually.- Specified by:
setContinuousTimeoutin interfaceMemcachedNode- Parameters:
isIncrease-
-
isAuthenticated
public boolean isAuthenticated()Description copied from interface:MemcachedNodeTrue if this node isauthenticated.
- Specified by:
isAuthenticatedin interfaceMemcachedNode
-
lastReadDelta
public long lastReadDelta()Description copied from interface:MemcachedNodeMilliseconds since last successful read.- Specified by:
lastReadDeltain interfaceMemcachedNode
-
completedRead
public void completedRead()Description copied from interface:MemcachedNodeNotify node of successful read. This is used so the node can keep track of any internal debugging or state it cares about on read.- Specified by:
completedReadin interfaceMemcachedNode
-
getConnection
- Specified by:
getConnectionin interfaceMemcachedNode
-
setConnection
- Specified by:
setConnectionin interfaceMemcachedNode
-