org.jgroups.protocols
Class RATE_LIMITER

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

public class RATE_LIMITER
extends Protocol

Protocol which sends at most max_bytes in time_period milliseconds. Can be used instead of a flow control protocol, e.g. FC or SFC (same position in the stack)

Author:
Bela Ban

Field Summary
protected  long end_of_current_period
           
protected  int frag_size
           
protected  java.util.concurrent.locks.Lock lock
           
protected  long max_bytes
           
protected  int num_blockings
           
protected  long num_bytes_sent_in_period
          Keeps track of the number of bytes sent in the current time period
protected  boolean running
           
protected  long time_period
           
protected  long time_period_ns
           
protected  long total_block_time
           
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
RATE_LIMITER()
           
 
Method Summary
 java.lang.Object down(Event evt)
          An event is to be sent down the stack.
 double getAverageBlockTime()
           
 long getMaxBytes()
           
 long getTimePeriod()
           
 long getTotalBlockTime()
           
 void init()
          Called after instance has been created (null constructor) and before protocol is started.
 void resetStats()
           
 void setMaxBytes(long max_bytes)
           
 void setTimePeriod(long time_period)
           
 void start()
          This method is called on a Channel.connect(String).
 void stop()
          This method is called on a Channel.disconnect().
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled, up
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

max_bytes

protected long max_bytes

time_period

protected long time_period

time_period_ns

protected long time_period_ns

num_bytes_sent_in_period

protected long num_bytes_sent_in_period
Keeps track of the number of bytes sent in the current time period


end_of_current_period

protected long end_of_current_period

lock

protected final java.util.concurrent.locks.Lock lock

num_blockings

protected int num_blockings

total_block_time

protected long total_block_time

frag_size

protected int frag_size

running

protected volatile boolean running
Constructor Detail

RATE_LIMITER

public RATE_LIMITER()
Method Detail

getMaxBytes

public long getMaxBytes()

setMaxBytes

public void setMaxBytes(long max_bytes)

getTimePeriod

public long getTimePeriod()

setTimePeriod

public void setTimePeriod(long time_period)

getTotalBlockTime

public long getTotalBlockTime()

getAverageBlockTime

public double getAverageBlockTime()

resetStats

public void resetStats()
Overrides:
resetStats in class Protocol

init

public void init()
          throws java.lang.Exception
Description copied from class: Protocol
Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.

Overrides:
init in class Protocol
Throws:
java.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the channel constructor will throw an exception

start

public void start()
           throws java.lang.Exception
Description copied from class: Protocol
This method is called on a Channel.connect(String). Starts work. Protocols are connected and queues are ready to receive events. Will be called from bottom to top. This call will replace the START and START_OK events.

Overrides:
start in class Protocol
Throws:
java.lang.Exception - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, so Channel.connect(String) will throw an exception

stop

public void stop()
Description copied from class: Protocol
This method is called on a Channel.disconnect(). Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed

Overrides:
stop in class Protocol

down

public java.lang.Object down(Event evt)
Description copied from class: Protocol
An event is to be sent down the stack. The layer may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the layer may need to add a header to it (or do nothing at all) before sending it down the stack using down_prot.down(). In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack using up_prot.up().

Overrides:
down in class Protocol


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.