Package org.jgroups.protocols
Class MFC
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.FlowControl
org.jgroups.protocols.MFC
- All Implemented Interfaces:
Lifecycle
- Direct Known Subclasses:
MFC_NB
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CreditMapMaintains credits per memberprotected longLast time a credit request was sent.protected static final FcHeaderprotected static final FcHeaderFields 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, runningFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected CreditMapcreateCreditMap(long max_creds) doubleprotected Headerintprotected Headerprotected voidhandleCredit(Address sender, long increase) protected ObjecthandleDownMessage(Message msg, int length) protected booleanWhether the protocol handles message with dest == null || dest.isMulticastAddress()protected voidhandleViewChange(List<Address> mbrs) voidinit()Called after a protocol has been created and before the protocol is started.protected booleanvoidvoidvoidstop()Called on aJChannel.disconnect(); stops work (e.g.voidunblock()Allows to unblock a blocked sender 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, printMap, printReceiverCredits, sendCredit, sendCreditRequest, setMaxBlockTime, setMaxCredits, setMinCredits, setMinThreshold, start, up, up, upMethods 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
-
Field Details
-
MFC_REPLENISH_HDR
-
MFC_CREDIT_REQUEST_HDR
-
credits
Maintains credits per member -
last_credit_request
protected long last_credit_requestLast time a credit request was sent. Used to prevent credit request storms
-
-
Constructor Details
-
MFC
public MFC()
-
-
Method Details
-
unblock
public void unblock()Allows to unblock a blocked sender from an external program, e.g. JMX- Overrides:
unblockin classFlowControl
-
replenish
-
printCredits
- Overrides:
printCreditsin classFlowControl
-
printSenderCredits
- Specified by:
printSenderCreditsin classFlowControl
-
getNumberOfBlockings
public int getNumberOfBlockings()- Specified by:
getNumberOfBlockingsin classFlowControl
-
getAverageTimeBlocked
public double getAverageTimeBlocked()- Specified by:
getAverageTimeBlockedin classFlowControl
-
handleMulticastMessage
protected boolean handleMulticastMessage()Description copied from class:FlowControlWhether the protocol handles message with dest == null || dest.isMulticastAddress()- Specified by:
handleMulticastMessagein classFlowControl
-
getReplenishHeader
- Specified by:
getReplenishHeaderin classFlowControl
-
getCreditRequestHeader
- Specified by:
getCreditRequestHeaderin classFlowControl
-
init
Description copied from class:ProtocolCalled after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent.- Specified by:
initin interfaceLifecycle- Overrides:
initin classFlowControl- Throws:
Exception- Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the the channel constructor will throw an exception
-
stop
public void stop()Description copied from class:ProtocolCalled on aJChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom.- Specified by:
stopin interfaceLifecycle- Overrides:
stopin classFlowControl
-
resetStats
public void resetStats()- Overrides:
resetStatsin classFlowControl
-
createCreditMap
-
handleDownMessage
- Specified by:
handleDownMessagein classFlowControl
-
needToSendCreditRequest
protected boolean needToSendCreditRequest() -
handleCredit
- Specified by:
handleCreditin classFlowControl
-
handleViewChange
- Overrides:
handleViewChangein classFlowControl
-