com.perforce.p4java.impl.mapbased.rpc.func.proto
Class FlowControl

java.lang.Object
  extended by com.perforce.p4java.impl.mapbased.rpc.func.proto.FlowControl

public class FlowControl
extends 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 Summary
static 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.
static int DEFAULT_LO_MARK
          Default maximum number of bytes allowed to be outstanding before we send a flush1 message on duplex commands.
static int FLUSH_CMD_LENGTH
          Length in bytes of a flush command when marshaled.
static String TRACE_PREFIX
           
 
Constructor Summary
FlowControl(RpcPacketDispatcher mainDispatcher, Properties props)
           
 
Method Summary
 void decrementCurrentHiMark(int decr)
           
 long getCurrentHiMark()
           
 long getCurrentLoMark()
           
 long getHiMark()
           
 long getLoMark()
           
 void incrementCurrentHiMark(int incr)
           
 void processFlushCommandFromServer(RpcConnection rpcConnection, RpcFunctionSpec funcSpec, Map<String,Object> resultsMap)
          Given a map passed-in from the main dispatcher that represents a flush command received from the Perforce server, respond appropriately.
 void sendFlush1(RpcConnection rpcConnection, Map<String,Object> resultsMap)
           
 void sendFlush2(RpcConnection rpcConnection, Map<String,Object> resultsMap)
           
 void setCurrentHiMark(long currentHiMark)
           
 void setCurrentLoMark(long currentLoMark)
           
 void setHiMark(long hiMark)
           
 void setLoMark(long loMark)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_PREFIX

public static final String TRACE_PREFIX
See Also:
Constant Field Values

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,
                   Properties props)
Method Detail

processFlushCommandFromServer

public void processFlushCommandFromServer(RpcConnection rpcConnection,
                                          RpcFunctionSpec funcSpec,
                                          Map<String,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...

Throws:
ConnectionException

sendFlush1

public void sendFlush1(RpcConnection rpcConnection,
                       Map<String,Object> resultsMap)

sendFlush2

public void sendFlush2(RpcConnection rpcConnection,
                       Map<String,Object> resultsMap)
                throws ConnectionException
Throws:
ConnectionException

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)


Copyright © 2015 Perforce Software. All Rights Reserved.