Class FlowControl
java.lang.Object
com.perforce.p4java.impl.mapbased.rpc.func.proto.FlowControl
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
FieldsModifier and TypeFieldDescriptionstatic final longDefault maximum number of bytes allowed to be outstanding before we start worrying that we haven't seen a suitable flush2 response.static final intDefault maximum number of bytes allowed to be outstanding before we send a flush1 message on duplex commands.static final intLength in bytes of a flush command when marshaled.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddecrementCurrentHiMark(int decr) longlonglonglongvoidincrementCurrentHiMark(int incr) voidprocessFlushCommandFromServer(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.voidsendFlush1(RpcConnection rpcConnection, Map<String, Object> resultsMap) voidsendFlush2(RpcConnection rpcConnection, Map<String, Object> resultsMap) voidsetCurrentHiMark(long currentHiMark) voidsetCurrentLoMark(long currentLoMark) voidsetHiMark(long hiMark) voidsetLoMark(long loMark)
-
Field Details
-
TRACE_PREFIX
- See Also:
-
FLUSH_CMD_LENGTH
public static final int FLUSH_CMD_LENGTHLength 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:
-
DEFAULT_LO_MARK
public static final int DEFAULT_LO_MARKDefault 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:
-
DEFAULT_HI_MARK
public static final long DEFAULT_HI_MARKDefault 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:
-
-
Constructor Details
-
FlowControl
-
-
Method Details
-
processFlushCommandFromServer
public void processFlushCommandFromServer(RpcConnection rpcConnection, RpcFunctionSpec funcSpec, Map<String, Object> resultsMap) throws ConnectionExceptionGiven 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- connectionfuncSpec- specresultsMap- map- Throws:
ConnectionException- on error
-
sendFlush1
-
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)
-