Class MemcachedNodeROImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private MemcachedNode root  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addOp​(Operation op)
      Add an operation to the queue.
      void authComplete()
      Let the node know that auth is complete.
      void completedRead()
      Notify node of successful 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 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.
      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.
      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()
      Milliseconds since last successful read.
      void reconnecting()
      Notify this node that it will be reconnecting.
      void registerChannel​(java.nio.channels.SocketChannel ch, java.nio.channels.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​(java.nio.channels.SocketChannel to)
      Set the SocketChannel this node uses.
      void setConnection​(MemcachedConnection connection)  
      void setContinuousTimeout​(boolean isIncrease)
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MemcachedNodeROImpl

        public MemcachedNodeROImpl​(MemcachedNode n)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • addOp

        public void addOp​(Operation op)
        Description copied from interface: MemcachedNode
        Add an operation to the queue. Authentication operations should never be added to the queue, but this is not checked.
        Specified by:
        addOp in interface MemcachedNode
      • insertOp

        public void insertOp​(Operation op)
        Description copied from interface: MemcachedNode
        Insert an operation to the beginning of the queue. This method is meant to be invoked rarely.
        Specified by:
        insertOp in interface MemcachedNode
      • connected

        public void connected()
        Description copied from interface: MemcachedNode
        Notify this node that it has reconnected.
        Specified by:
        connected in interface MemcachedNode
      • copyInputQueue

        public void copyInputQueue()
        Description copied from interface: MemcachedNode
        Move all of the operations delivered via addOperation into the internal write queue.
        Specified by:
        copyInputQueue in interface MemcachedNode
      • fillWriteBuffer

        public void fillWriteBuffer​(boolean optimizeGets)
        Description copied from interface: MemcachedNode
        Fill the write buffer with data from the next operations in the queue.
        Specified by:
        fillWriteBuffer in interface MemcachedNode
        Parameters:
        optimizeGets - if true, combine sequential gets into a single multi-key get
      • fixupOps

        public void fixupOps()
        Description copied from interface: MemcachedNode
        Fix up the selection ops on the selection key.
        Specified by:
        fixupOps in interface MemcachedNode
      • getChannel

        public java.nio.channels.SocketChannel getChannel()
        Description copied from interface: MemcachedNode
        Get the SocketChannel for this connection.
        Specified by:
        getChannel in interface MemcachedNode
      • getRbuf

        public java.nio.ByteBuffer getRbuf()
        Description copied from interface: MemcachedNode
        Get the buffer used for reading data from this node.
        Specified by:
        getRbuf in interface MemcachedNode
      • getSelectionOps

        public int getSelectionOps()
        Description copied from interface: MemcachedNode
        Compute the appropriate selection operations for the channel this MemcachedNode holds to the server.
        Specified by:
        getSelectionOps in interface MemcachedNode
      • getSk

        public java.nio.channels.SelectionKey getSk()
        Description copied from interface: MemcachedNode
        Get the selection key from this node.
        Specified by:
        getSk in interface MemcachedNode
      • getSocketAddress

        public java.net.SocketAddress getSocketAddress()
        Description copied from interface: MemcachedNode
        Get the SocketAddress of the server to which this node is connected.
        Specified by:
        getSocketAddress in interface MemcachedNode
      • getWbuf

        public java.nio.ByteBuffer getWbuf()
        Description copied from interface: MemcachedNode
        Get the buffer used for writing data to this node.
        Specified by:
        getWbuf in interface MemcachedNode
      • hasReadOp

        public boolean hasReadOp()
        Description copied from interface: MemcachedNode
        True if an operation is available to read.
        Specified by:
        hasReadOp in interface MemcachedNode
      • hasWriteOp

        public boolean hasWriteOp()
        Description copied from interface: MemcachedNode
        True if an operation is available to write.
        Specified by:
        hasWriteOp in interface MemcachedNode
      • isActive

        public boolean isActive()
        Description copied from interface: MemcachedNode
        True if this node is active. i.e. is is currently connected and expected to be able to process requests
        Specified by:
        isActive in interface MemcachedNode
      • reconnecting

        public void reconnecting()
        Description copied from interface: MemcachedNode
        Notify this node that it will be reconnecting.
        Specified by:
        reconnecting in interface MemcachedNode
      • registerChannel

        public void registerChannel​(java.nio.channels.SocketChannel ch,
                                    java.nio.channels.SelectionKey selectionKey)
        Description copied from interface: MemcachedNode
        Register a channel with this node.
        Specified by:
        registerChannel in interface MemcachedNode
      • setChannel

        public void setChannel​(java.nio.channels.SocketChannel to)
        Description copied from interface: MemcachedNode
        Set the SocketChannel this node uses.
        Specified by:
        setChannel in interface MemcachedNode
      • setSk

        public void setSk​(java.nio.channels.SelectionKey to)
        Description copied from interface: MemcachedNode
        Set the selection key for this node.
        Specified by:
        setSk in interface MemcachedNode
      • setupResend

        public void setupResend()
        Description copied from interface: MemcachedNode
        Clear the queue of currently processing operations by either cancelling them or setting them up to be reapplied after a reconnect.
        Specified by:
        setupResend in interface MemcachedNode
      • writeSome

        public int writeSome()
                      throws java.io.IOException
        Description copied from interface: MemcachedNode
        Write some bytes and return the number of bytes written.
        Specified by:
        writeSome in interface MemcachedNode
        Returns:
        the number of bytes written
        Throws:
        java.io.IOException - if there's a problem writing
      • destroyInputQueue

        public java.util.Collection<Operation> destroyInputQueue()
        Description copied from interface: MemcachedNode
        Extract all queued items for this node destructively. This is useful for redistributing items.
        Specified by:
        destroyInputQueue in interface MemcachedNode
      • authComplete

        public void authComplete()
        Description copied from interface: MemcachedNode
        Let 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:
        authComplete in interface MemcachedNode
      • setupForAuth

        public void setupForAuth()
        Description copied from interface: MemcachedNode
        Tell 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:
        setupForAuth in interface MemcachedNode
      • setContinuousTimeout

        public void setContinuousTimeout​(boolean isIncrease)
        Description copied from interface: MemcachedNode
        Count 'time out' exceptions to drop connections that fail perpetually.
        Specified by:
        setContinuousTimeout in interface MemcachedNode
      • completedRead

        public void completedRead()
        Description copied from interface: MemcachedNode
        Notify 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:
        completedRead in interface MemcachedNode