Package org.jgroups.protocols
Class RATE_LIMITER
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.RATE_LIMITER
- All Implemented Interfaces:
Lifecycle
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)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected intprotected final Lockprotected longprotected intprotected longKeeps track of the number of bytes sent in the current time periodprotected booleanprotected longprotected longprotected longFields 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 TypeMethodDescriptionAn event is to be sent down the stack.A message is sent down the stack.doublelonglonglongvoidinit()Called after a protocol has been created and before the protocol is started.voidvoidsetMaxBytes(long max_bytes) voidsetTimePeriod(long time_period) voidstart()This method is called on aJChannel.connect(String); starts work.voidstop()Called on aJChannel.disconnect(); stops work (e.g.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, up, up, up
-
Field Details
-
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_periodKeeps track of the number of bytes sent in the current time period -
current_period_start
protected long current_period_start -
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 Details
-
RATE_LIMITER
public RATE_LIMITER()
-
-
Method Details
-
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
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. -
start
Description copied from class:ProtocolThis method is called on aJChannel.connect(String); starts work. Protocols are connected ready to receive events. Will be called from bottom to top. -
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. -
down
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(). -
down
Description copied from class:ProtocolA message is sent down the stack. Protocols may examine the message and do something (e.g. add a header) with it, before passing it down.
-