Class FlowControl


  • public class FlowControl
    extends java.lang.Object
    Process and implement the various Perforce flow control commands, in particular the flush1 / flush2 pair.

    In general, we keep a count of outstanding bytes and send a flush1 when it gets above the high water mark (hwm); we then wait for a corresponding flush2 before doing much else. The server does the same thing in reverse. This will all be explained in more detail later when the full implementation is much clearer... (HR).

    • Field Detail

      • FLUSH_CMD_LENGTH

        public static final int FLUSH_CMD_LENGTH
        Length in bytes of a flush command when marshaled. This is actually a fiction -- it's more like 50 -- but the conservative sizing gives us a little leeway when things are tight (see the C++ API for a discussion on this -- we're just copying their behavior...).
        See Also:
        Constant Field Values
      • DEFAULT_LO_MARK

        public static final int DEFAULT_LO_MARK
        Default maximum number of bytes allowed to be outstanding before we send a flush1 message on duplex commands. See the flow control documentation for an explanation of this and associated gubbins.
        See Also:
        Constant Field Values
      • DEFAULT_HI_MARK

        public static final long DEFAULT_HI_MARK
        Default maximum number of bytes allowed to be outstanding before we start worrying that we haven't seen a suitable flush2 response. See the flow control documentation for an explanation of this and associated gubbins.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FlowControl

        public FlowControl​(RpcPacketDispatcher mainDispatcher,
                           java.util.Properties props)
    • Method Detail

      • processFlushCommandFromServer

        public void processFlushCommandFromServer​(RpcConnection rpcConnection,
                                                  RpcFunctionSpec funcSpec,
                                                  java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
                                           throws ConnectionException
        Given a map passed-in from the main dispatcher that represents a flush command received from the Perforce server, respond appropriately. What "appropriately" means is very context-dependent; in general, if we see a flush1 we immediately attempt to send a flush2 with the same sequence number. If we see a flush2 we try to match it up with any outstanding flush1's we've already sent. This can get arbitrarily complex...
        Parameters:
        rpcConnection - connection
        funcSpec - spec
        resultsMap - map
        Throws:
        ConnectionException - on error
      • sendFlush1

        public void sendFlush1​(RpcConnection rpcConnection,
                               java.util.Map<java.lang.String,​java.lang.Object> resultsMap)
      • incrementCurrentHiMark

        public void incrementCurrentHiMark​(int incr)
      • decrementCurrentHiMark

        public void decrementCurrentHiMark​(int decr)
      • getLoMark

        public long getLoMark()
      • setLoMark

        public void setLoMark​(long loMark)
      • getHiMark

        public long getHiMark()
      • setHiMark

        public void setHiMark​(long hiMark)
      • getCurrentLoMark

        public long getCurrentLoMark()
      • setCurrentLoMark

        public void setCurrentLoMark​(long currentLoMark)
      • getCurrentHiMark

        public long getCurrentHiMark()
      • setCurrentHiMark

        public void setCurrentHiMark​(long currentHiMark)