|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jgroups.stack.Protocol org.jgroups.protocols.RATE_LIMITER
public class RATE_LIMITER
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)
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 |
---|
protected long max_bytes
protected long time_period
protected long time_period_ns
protected long num_bytes_sent_in_period
protected long end_of_current_period
protected final java.util.concurrent.locks.Lock lock
protected int num_blockings
protected long total_block_time
protected int frag_size
protected volatile boolean running
Constructor Detail |
---|
public RATE_LIMITER()
Method Detail |
---|
public long getMaxBytes()
public void setMaxBytes(long max_bytes)
public long getTimePeriod()
public void setTimePeriod(long time_period)
public long getTotalBlockTime()
public double getAverageBlockTime()
public void resetStats()
resetStats
in class Protocol
public void init() throws java.lang.Exception
Protocol
init
in class Protocol
java.lang.Exception
- Thrown if protocol cannot be initialized successfully. This will cause the
ProtocolStack to fail, so the channel constructor will throw an exceptionpublic void start() throws java.lang.Exception
Protocol
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.
start
in class Protocol
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void stop()
Protocol
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
stop
in class Protocol
public java.lang.Object down(Event evt)
Protocol
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()
.
down
in class Protocol
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |