Top Description Fields Constructors Methods
org.osgi.util.pushstream

public final Class ThresholdPushbackPolicy<T, U extends BlockingQueue<PushEvent<? extends T>>>

extends Object
implements PushbackPolicy<T, U extends BlockingQueue<PushEvent<? extends T>>>
Class Inheritance
All Implemented Interfaces
org.osgi.util.pushstream.PushbackPolicy
Type Parameters
<T>
The type of objects in the PushEvent
<U>
The type of the Queue used in the user specified buffer
Imports
java.util.concurrent.BlockingQueue

Provides a configurable PushbackPolicy implementation that returns zero back pressure until the buffer fills beyond the supplied threshold. Once the threshold is reached back pressure is returned based on the supplied parameters.

The starting level of the back pressure once the threshold is exceeded is defined using the initial parameter. Additional back pressure is applied for each queued item over the threshold. The amount of this additional back pressure is defined by the increment parameter.

The following common use cases are supported:

Since
1.1

Field Summary

Modifier and TypeField and Description
private final long
private final long
private final int

Constructor Summary

AccessConstructor and Description
private
ThresholdPushbackPolicy(int
the queue size limit after which back pressure will be applied
threshold
,
long
the initial back pressure which defines the floor after the threshold is exceeded
initial
,
long
the increments in which the pressure increases.
increment
)

Method Summary

Modifier and TypeMethod and Description
public static <T, U extends BlockingQueue<PushEvent<? extends T>>> ThresholdPushbackPolicy<T, U>
createIncrementalThresholdPushbackPolicy(int
the queue size limit after which back pressure will be applied
threshold
,
long
the increments in which the pressure increases
increment
)

A simple configuration, where the increment size is used as the initial back pressure.

public static <T, U extends BlockingQueue<PushEvent<? extends T>>> ThresholdPushbackPolicy<T, U>
createSimpleThresholdPushbackPolicy(int
the queue size limit after which back pressure will be applied
threshold
)

A simple configuration with an initial back pressure of one and and increase increment size of one.

public static <T, U extends BlockingQueue<PushEvent<? extends T>>> ThresholdPushbackPolicy<T, U>
createThresholdPushbackPolicy(int
the queue size limit after which back pressure will be applied
threshold
,
long
the initial back pressure which defines the floor after the threshold is exceeded
initial
,
long
the increments in which the pressure increases.
increment
)

Provides a ThresholdPushbackPolicy with an individual configuration for all possible parameters.

public long
pushback(U queue)

Implements org.osgi.util.pushstream.PushbackPolicy.pushback.

Given the current state of the queue, determine the level of back pressure that should be applied

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

incrementback to summary
private final long increment
initialback to summary
private final long initial
thresholdback to summary
private final int threshold

Constructor Detail

ThresholdPushbackPolicyback to summary
private ThresholdPushbackPolicy(int threshold, long initial, long increment)
Parameters
threshold:int

the queue size limit after which back pressure will be applied

initial:long

the initial back pressure which defines the floor after the threshold is exceeded

increment:long

the increments in which the pressure increases.

Exceptions
IllegalArgumentException:
if any of the given values is lower then zero

Method Detail

createIncrementalThresholdPushbackPolicyback to summary
public static <T, U extends BlockingQueue<PushEvent<? extends T>>> ThresholdPushbackPolicy<T, U> createIncrementalThresholdPushbackPolicy(int threshold, long increment)

A simple configuration, where the increment size is used as the initial back pressure.

Parameters
threshold:int

the queue size limit after which back pressure will be applied

increment:long

the increments in which the pressure increases

Returns:ThresholdPushbackPolicy<T, U>

a new ThresholdPushbackPolicy

Exceptions
IllegalArgumentException:
if any of the given values is lower then zero
See Also
createThresholdPushbackPolicy(int threshold, long initial, long increment)
createSimpleThresholdPushbackPolicyback to summary
public static <T, U extends BlockingQueue<PushEvent<? extends T>>> ThresholdPushbackPolicy<T, U> createSimpleThresholdPushbackPolicy(int threshold)

A simple configuration with an initial back pressure of one and and increase increment size of one.

Parameters
threshold:int

the queue size limit after which back pressure will be applied

Returns:ThresholdPushbackPolicy<T, U>

a new ThresholdPushbackPolicy

Exceptions
IllegalArgumentException:
if any of the given values is lower then zero
See Also
createThresholdPushbackPolicy(int threshold, long initial, long increment)
createThresholdPushbackPolicyback to summary
public static <T, U extends BlockingQueue<PushEvent<? extends T>>> ThresholdPushbackPolicy<T, U> createThresholdPushbackPolicy(int threshold, long initial, long increment)

Provides a ThresholdPushbackPolicy with an individual configuration for all possible parameters.

Parameters
threshold:int

the queue size limit after which back pressure will be applied

initial:long

the initial back pressure which defines the floor after the threshold is exceeded

increment:long

the increments in which the pressure increases.

Returns:ThresholdPushbackPolicy<T, U>

a new ThresholdPushbackPolicy

Exceptions
IllegalArgumentException:
if any of the given values is lower then zero
pushbackback to summary
public long pushback(U queue) throws Exception

Implements org.osgi.util.pushstream.PushbackPolicy.pushback.

Doc from org.osgi.util.pushstream.PushbackPolicy.pushback.

Given the current state of the queue, determine the level of back pressure that should be applied

Returns:long

a back pressure value in nanoseconds

Annotations
@Override