org.jgroups.protocols
Class FC

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.FC

public class FC
extends org.jgroups.stack.Protocol

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:

  1. Receivers now send credits to a sender when more than min_credits have been received (rather than when min_credits are left)
  2. Receivers don't send the full credits (max_credits), but rather tha actual number of bytes received

      Version:
      $Id: FC.java,v 1.86.2.1 2007/12/18 07:58:17 belaban Exp $
      Author:
      Bela Ban

      Nested Class Summary
      static class FC.FcHeader
                 
       
      Field Summary
       
      Fields inherited from class org.jgroups.stack.Protocol
      down_prot, log, props, stack, stats, up_prot
       
      Constructor Summary
      FC()
                 
       
      Method Summary
       java.lang.Object down(org.jgroups.Event evt)
                 
       java.util.Map<java.lang.String,java.lang.Object> dumpStats()
                 
       double getAverageTimeBlocked()
                 
       long getLowest_max_credits()
                 
       long getMaxBlockTime()
                 
       long getMaxCredits()
                 
       long getMinCredits()
                 
       double getMinThreshold()
                 
       java.lang.String getName()
                 
       int getNumberOfBlockings()
                 
       int getNumberOfCreditRequestsReceived()
                 
       int getNumberOfCreditRequestsSent()
                 
       int getNumberOfCreditResponsesReceived()
                 
       int getNumberOfCreditResponsesSent()
                 
       long getTotalTimeBlocked()
                 
       java.lang.String printCredits()
                 
       java.lang.String printReceiverCredits()
                 
       java.lang.String printSenderCredits()
                 
       void resetStats()
                 
       void setLowest_max_credits(long lowest_max_credits)
                 
       void setMaxBlockTime(long t)
                 
       void setMaxCredits(long max_credits)
                 
       void setMinCredits(long min_credits)
                 
       void setMinThreshold(double min_threshold)
                 
       boolean setProperties(java.util.Properties props)
                 
       java.lang.String showLastBlockingTimes()
                 
       void start()
                 
       void stop()
                 
       void unblock()
                Allows to unblock a blocked sender from an external program, e.g.
       java.lang.Object up(org.jgroups.Event evt)
                 
       
      Methods inherited from class org.jgroups.stack.Protocol
      destroy, downThreadEnabled, enableStats, getDownProtocol, getProperties, getUpProtocol, init, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, setDownProtocol, setPropertiesInternal, setProtocolStack, setUpProtocol, statsEnabled, upThreadEnabled
       
      Methods inherited from class java.lang.Object
      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
       

      Constructor Detail

      FC

      public FC()
      Method Detail

      down

      public java.lang.Object down(org.jgroups.Event evt)
      Overrides:
      down in class org.jgroups.stack.Protocol

      dumpStats

      public java.util.Map<java.lang.String,java.lang.Object> dumpStats()
      Overrides:
      dumpStats in class org.jgroups.stack.Protocol

      getAverageTimeBlocked

      public double getAverageTimeBlocked()

      getLowest_max_credits

      public long getLowest_max_credits()

      getMaxBlockTime

      public long getMaxBlockTime()

      getMaxCredits

      public long getMaxCredits()

      getMinCredits

      public long getMinCredits()

      getMinThreshold

      public double getMinThreshold()

      getName

      public final java.lang.String getName()
      Specified by:
      getName in class org.jgroups.stack.Protocol

      getNumberOfBlockings

      public int getNumberOfBlockings()

      getNumberOfCreditRequestsReceived

      public int getNumberOfCreditRequestsReceived()

      getNumberOfCreditRequestsSent

      public int getNumberOfCreditRequestsSent()

      getNumberOfCreditResponsesReceived

      public int getNumberOfCreditResponsesReceived()

      getNumberOfCreditResponsesSent

      public int getNumberOfCreditResponsesSent()

      getTotalTimeBlocked

      public long getTotalTimeBlocked()

      printCredits

      public java.lang.String printCredits()

      printReceiverCredits

      public java.lang.String printReceiverCredits()

      printSenderCredits

      public java.lang.String printSenderCredits()

      resetStats

      public void resetStats()
      Overrides:
      resetStats in class org.jgroups.stack.Protocol

      setLowest_max_credits

      public void setLowest_max_credits(long lowest_max_credits)

      setMaxBlockTime

      public void setMaxBlockTime(long t)

      setMaxCredits

      public void setMaxCredits(long max_credits)

      setMinCredits

      public void setMinCredits(long min_credits)

      setMinThreshold

      public void setMinThreshold(double min_threshold)

      setProperties

      public boolean setProperties(java.util.Properties props)
      Overrides:
      setProperties in class org.jgroups.stack.Protocol

      showLastBlockingTimes

      public java.lang.String showLastBlockingTimes()

      start

      public void start()
                 throws java.lang.Exception
      Overrides:
      start in class org.jgroups.stack.Protocol
      Throws:
      java.lang.Exception

      stop

      public void stop()
      Overrides:
      stop in class org.jgroups.stack.Protocol

      unblock

      public void unblock()
      Allows to unblock a blocked sender from an external program, e.g. JMX


      up

      public java.lang.Object up(org.jgroups.Event evt)
      Overrides:
      up in class org.jgroups.stack.Protocol