Top Description Inners Fields Constructors Methods
org.eclipse.jetty.http2

public Class WindowRateControl

extends Object
implements RateControl
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.http2.RateControl
Imports
java.time.Duration, java.util.Queue, java.util.concurrent.ConcurrentLinkedQueue, java.util.concurrent.atomic.AtomicInteger, org.eclipse.jetty.io.EndPoint, org.eclipse.jetty.util.NanoTime

An implementation of RateControl that limits the number of events within a time period.

Events are kept in a queue and for each event the queue is first drained of the old events outside the time window, and then the new event is added to the queue. The size of the queue is maintained separately in an AtomicInteger and if it exceeds the max number of events then onEvent(Object) returns false.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final Queue<Long>
private final int
private final AtomicInteger
private final long

Constructor Summary

AccessConstructor and Description
public
WindowRateControl(int maxEvents, Duration window)

Method Summary

Modifier and TypeMethod and Description
public static WindowRateControl
fromEventsPerSecond(int maxEvents)

public int
public boolean
onEvent(Object
the event subject to rate control.
event
)

Implements org.eclipse.jetty.http2.RateControl.onEvent.

Applications should call this method when they want to signal an event that is subject to rate control.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

eventsback to summary
private final Queue<Long> events
maxEventsback to summary
private final int maxEvents
sizeback to summary
private final AtomicInteger size
windowback to summary
private final long window

Constructor Detail

WindowRateControlback to summary
public WindowRateControl(int maxEvents, Duration window)

Method Detail

fromEventsPerSecondback to summary
public static WindowRateControl fromEventsPerSecond(int maxEvents)
getEventsPerSecondback to summary
public int getEventsPerSecond()
onEventback to summary
public boolean onEvent(Object event)

Implements org.eclipse.jetty.http2.RateControl.onEvent.

Doc from org.eclipse.jetty.http2.RateControl.onEvent.

Applications should call this method when they want to signal an event that is subject to rate control.

Implementations should return true if the event does not exceed the desired rate, or false to signal that the event exceeded the desired rate.

Parameters
event:Object

the event subject to rate control.

Returns:boolean

true IFF the rate is within limits

Annotations
@Override
org.eclipse.jetty.http2 back to summary

public Class WindowRateControl.Factory

extends Object
implements Factory
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.http2.RateControl.Factory

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
public
Factory(int maxEventRate)

Method Summary

Modifier and TypeMethod and Description
public RateControl
newRateControl(EndPoint
the EndPoint for which the RateControl is created
endPoint
)

Overrides default org.eclipse.jetty.http2.RateControl.Factory.newRateControl.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

maxEventRateback to summary
private final int maxEventRate

Constructor Detail

Factoryback to summary
public Factory(int maxEventRate)

Method Detail

newRateControlback to summary
public RateControl newRateControl(EndPoint endPoint)

Overrides default org.eclipse.jetty.http2.RateControl.Factory.newRateControl.

Parameters
endPoint:EndPoint

Doc from org.eclipse.jetty.http2.RateControl.Factory.newRateControl.

the EndPoint for which the RateControl is created

Returns:RateControl

Doc from org.eclipse.jetty.http2.RateControl.Factory.newRateControl.

a new RateControl instance for the given EndPoint

Annotations
@Override