Package org.jgroups.protocols
Class UFC
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.FlowControl
-
- org.jgroups.protocols.UFC
-
- All Implemented Interfaces:
Lifecycle
- Direct Known Subclasses:
UFC_NB
public class UFC extends FlowControl
Simple flow control protocol based on a credit system. Each sender has a number of credits (bytes to send). When the credits have been exhausted, the sender blocks. Each receiver also keeps track of how many credits it has received from a sender. When credits for a sender fall below a threshold, the receiver sends more credits to the sender. Works for both unicast and multicast messages. Note that this protocol must be located towards the top of the stack, or all down_threads from JChannel to this protocol must be set to false ! This is in order to block JChannel.send()/JChannel.down().
This is the second simplified implementation of the same model. The algorithm is sketched out in doc/FlowControl.txt
Changes (Brian) April 2006:- Receivers now send credits to a sender when more than min_credits have been received (rather than when min_credits are left)
- Receivers don't send the full credits (max_credits), but rather the actual number of bytes received
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<Address,? extends Credit>
sent
Map: keys are members, values are credits left.protected static FcHeader
UFC_CREDIT_REQUEST_HDR
protected static FcHeader
UFC_REPLENISH_HDR
-
Fields inherited from class org.jgroups.protocols.FlowControl
frag_size, max_block_time, max_credits, min_credits, min_threshold, num_credit_requests_received, num_credit_requests_sent, num_credit_responses_received, num_credit_responses_sent, num_msgs_dropped, received, running
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description UFC()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T extends Credit>
TcreateCredit(int initial_credits)
double
getAverageTimeBlocked()
protected Header
getCreditRequestHeader()
int
getNumberOfBlockings()
protected Header
getReplenishHeader()
long
getSenderCreditsFor(Address mbr)
protected void
handleCredit(Address sender, long increase)
protected java.lang.Object
handleDownMessage(Message msg, int length)
protected boolean
handleMulticastMessage()
Whether the protocol handles message with dest == null || dest.isMulticastAddress()protected void
handleViewChange(java.util.List<Address> mbrs)
java.lang.String
printCredits()
java.lang.String
printSenderCredits()
void
resetStats()
void
stop()
Called on aJChannel.disconnect()
; stops work (e.g.void
unblock()
Allows to unblock all blocked senders from an external program, e.g.-
Methods inherited from class org.jgroups.protocols.FlowControl
adjustCredit, down, down, getMaxBlockTime, getMaxCredits, getMinCredits, getMinThreshold, getNumberOfCreditRequestsReceived, getNumberOfCreditRequestsSent, getNumberOfCreditResponsesReceived, getNumberOfCreditResponsesSent, getReceiverCreditsFor, handleConfigEvent, handleCreditRequest, handleUpEvent, init, printMap, printReceiverCredits, sendCredit, sendCreditRequest, setMaxBlockTime, setMaxCredits, setMinCredits, setMinThreshold, start, up, up, up
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString
-
-
-
-
Method Detail
-
printSenderCredits
public java.lang.String printSenderCredits()
- Specified by:
printSenderCredits
in classFlowControl
-
printCredits
public java.lang.String printCredits()
- Overrides:
printCredits
in classFlowControl
-
handleMulticastMessage
protected boolean handleMulticastMessage()
Description copied from class:FlowControl
Whether the protocol handles message with dest == null || dest.isMulticastAddress()- Specified by:
handleMulticastMessage
in classFlowControl
-
getReplenishHeader
protected Header getReplenishHeader()
- Specified by:
getReplenishHeader
in classFlowControl
-
getCreditRequestHeader
protected Header getCreditRequestHeader()
- Specified by:
getCreditRequestHeader
in classFlowControl
-
unblock
public void unblock()
Description copied from class:FlowControl
Allows to unblock all blocked senders from an external program, e.g. JMX- Overrides:
unblock
in classFlowControl
-
getSenderCreditsFor
public long getSenderCreditsFor(Address mbr)
-
getNumberOfBlockings
public int getNumberOfBlockings()
- Specified by:
getNumberOfBlockings
in classFlowControl
-
getAverageTimeBlocked
public double getAverageTimeBlocked()
- Specified by:
getAverageTimeBlocked
in classFlowControl
-
stop
public void stop()
Description copied from class:Protocol
Called on aJChannel.disconnect()
; stops work (e.g. by closing multicast socket). Will be called from top to bottom.- Specified by:
stop
in interfaceLifecycle
- Overrides:
stop
in classFlowControl
-
resetStats
public void resetStats()
- Overrides:
resetStats
in classFlowControl
-
handleDownMessage
protected java.lang.Object handleDownMessage(Message msg, int length)
- Specified by:
handleDownMessage
in classFlowControl
-
handleViewChange
protected void handleViewChange(java.util.List<Address> mbrs)
- Overrides:
handleViewChange
in classFlowControl
-
handleCredit
protected void handleCredit(Address sender, long increase)
- Specified by:
handleCredit
in classFlowControl
-
createCredit
protected <T extends Credit> T createCredit(int initial_credits)
-
-