Package org.jgroups.protocols
Class RATE_LIMITER
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- 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. UFC or MFC (same position in the stack)- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected longcurrent_period_startprotected intfrag_sizeprotected java.util.concurrent.locks.Locklockprotected longmax_bytesprotected intnum_blockingsprotected longnum_bytes_sent_in_periodKeeps track of the number of bytes sent in the current time periodprotected booleanrunningprotected longtime_periodprotected longtime_period_nsprotected longtotal_block_time-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description RATE_LIMITER()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectdown(Event evt)An event is to be sent down the stack.java.lang.Objectdown(Message msg)A message is sent down the stack.doublegetAverageBlockTime()longgetMaxBytes()longgetTimePeriod()longgetTotalBlockTime()voidinit()Called after instance has been created (null constructor) and before protocol is started.voidresetStats()voidsetMaxBytes(long max_bytes)voidsetTimePeriod(long time_period)voidstart()This method is called on aJChannel.connect(String).voidstop()This method is called on aJChannel.disconnect().-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, destroy, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, up, up, up
-
-
-
-
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
-
current_period_start
protected long current_period_start
-
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
-
-
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:
resetStatsin classProtocol
-
init
public void init() throws java.lang.ExceptionDescription copied from class:ProtocolCalled 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.
-
start
public void start() throws java.lang.ExceptionDescription copied from class:ProtocolThis method is called on aJChannel.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:
startin classProtocol- Throws:
java.lang.Exception- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, soJChannel.connect(String)will throw an exception
-
stop
public void stop()
Description copied from class:ProtocolThis method is called on aJChannel.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
-
down
public java.lang.Object down(Event evt)
Description copied from class:ProtocolAn event is to be sent down the stack. A protocol 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 protocol may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down().
-
-