Top Description Inners Fields Constructors Methods
io.netty.handler.codec.http2

public final Class WeightedFairQueueByteDistributor

extends Object
implements StreamByteDistributor
Class Inheritance
All Implemented Interfaces
io.netty.handler.codec.http2.StreamByteDistributor
Annotations
@UnstableApi
Imports
io.netty.util.collection.IntCollections, .IntObjectHashMap, .IntObjectMap, io.netty.util.internal.DefaultPriorityQueue, .EmptyPriorityQueue, .MathUtil, .PriorityQueue, .PriorityQueueNode, .SystemPropertyUtil, .UnstableApi, java.io.Serializable, java.util.ArrayList, .Comparator, .Iterator, .List

A StreamByteDistributor that is sensitive to stream priority and uses Weighted Fair Queueing approach for distributing bytes.

Inspiration for this distributor was taken from Linux's Completely Fair Scheduler to model the distribution of bytes to simulate an "ideal multi-tasking CPU", but in this case we are simulating an "ideal multi-tasking NIC".

Each write operation will use the allocationQuantum(int) to know how many more bytes should be allocated relative to the next stream which wants to write. This is to balance fairness while also considering goodput.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
WeightedFairQueueByteDistributor.ParentChangedEvent

Allows a correlation to be made between a stream and its old parent before a parent change occurs.

private class
WeightedFairQueueByteDistributor.State

The remote flow control state for a single stream.

private static class
WeightedFairQueueByteDistributor.StateOnlyComparator

A comparator for State which has no associated Http2Stream object.

private static class

Field Summary

Modifier and TypeField and Description
private int
allocationQuantum

The minimum number of bytes that we will attempt to allocate to a stream.

private final Http2Connection
private final WeightedFairQueueByteDistributor.State
private static final int
DEFAULT_MAX_STATE_ONLY_SIZE

FireFox currently uses 5 streams to establish QoS classes.

pack-priv static final int
INITIAL_CHILDREN_MAP_SIZE

The initial size of the children map is chosen to be conservative on initial memory allocations under the assumption that most streams will have a small number of children.

private final int
private final Http2Connection.PropertyKey
private final IntObjectMap<WeightedFairQueueByteDistributor.State>
stateOnlyMap

If there is no Http2Stream object, but we still persist priority information then this is where the state will reside.

private final PriorityQueue<WeightedFairQueueByteDistributor.State>
stateOnlyRemovalQueue

This queue will hold streams that are not active and provides the capability to retain priority for streams which have no Http2Stream object.

Constructor Summary

AccessConstructor and Description
public
public
WeightedFairQueueByteDistributor(Http2Connection connection, int maxStateOnlySize)

Method Summary

Modifier and TypeMethod and Description
public void
allocationQuantum(int
the amount of bytes that will be allocated to each stream. Must be > 0.
allocationQuantum
)

Sets the amount of bytes that will be allocated to each stream.

public boolean
distribute(int
the maximum number of bytes to write.
maxBytes
,
StreamByteDistributor.Writer writer)

Implements io.netty.handler.codec.http2.StreamByteDistributor.distribute.

Distributes up to maxBytes to those streams containing streamable bytes and iterates across those streams to write the appropriate bytes.
private int
private int
distributeToChildren(int maxBytes, StreamByteDistributor.Writer writer, WeightedFairQueueByteDistributor.State state)

It is a pre-condition that state.poll() returns a non-null value.

pack-priv boolean
isChild(int childId, int parentId, short weight)

For testing only!

pack-priv void
notifyParentChanged(List<WeightedFairQueueByteDistributor.ParentChangedEvent>
The events (top down order) which have changed
events
)

Notify all listeners of the priority tree change events (in ascending order)

pack-priv int
numChildren(int streamId)

For testing only!

private WeightedFairQueueByteDistributor.State
private WeightedFairQueueByteDistributor.State
state(int streamId)

public void
updateDependencyTree(int
The stream identifier associated with the child stream.
childStreamId
,
int
The stream identifier associated with the parent stream. May be 0, to make childStreamId and immediate child of the connection.
parentStreamId
,
short
The weight which is used relative to other child streams for parentStreamId. This value must be between 1 and 256 (inclusive).
weight
,
boolean
If childStreamId should be the exclusive dependency of parentStreamId.
exclusive
)

Implements io.netty.handler.codec.http2.StreamByteDistributor.updateDependencyTree.

Explicitly update the dependency tree.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allocationQuantumback to summary
private int allocationQuantum

The minimum number of bytes that we will attempt to allocate to a stream. This is to help improve goodput on a per-stream basis.

connectionback to summary
private final Http2Connection connection
connectionStateback to summary
private final WeightedFairQueueByteDistributor.State connectionState
DEFAULT_MAX_STATE_ONLY_SIZEback to summary
private static final int DEFAULT_MAX_STATE_ONLY_SIZE

FireFox currently uses 5 streams to establish QoS classes.

INITIAL_CHILDREN_MAP_SIZEback to summary
pack-priv static final int INITIAL_CHILDREN_MAP_SIZE

The initial size of the children map is chosen to be conservative on initial memory allocations under the assumption that most streams will have a small number of children. This choice may be sub-optimal if when children are present there are many children (i.e. a web page which has many dependencies to load). Visible only for testing!

maxStateOnlySizeback to summary
private final int maxStateOnlySize
stateKeyback to summary
private final Http2Connection.PropertyKey stateKey
stateOnlyMapback to summary
private final IntObjectMap<WeightedFairQueueByteDistributor.State> stateOnlyMap

If there is no Http2Stream object, but we still persist priority information then this is where the state will reside.

stateOnlyRemovalQueueback to summary
private final PriorityQueue<WeightedFairQueueByteDistributor.State> stateOnlyRemovalQueue

This queue will hold streams that are not active and provides the capability to retain priority for streams which have no Http2Stream object. See StateOnlyComparator for the priority comparator.

Constructor Detail

WeightedFairQueueByteDistributorback to summary
public WeightedFairQueueByteDistributor(Http2Connection connection)
WeightedFairQueueByteDistributorback to summary
public WeightedFairQueueByteDistributor(Http2Connection connection, int maxStateOnlySize)

Method Detail

allocationQuantumback to summary
public void allocationQuantum(int allocationQuantum)

Sets the amount of bytes that will be allocated to each stream. Defaults to 1KiB.

Parameters
allocationQuantum:int

the amount of bytes that will be allocated to each stream. Must be > 0.

distributeback to summary
public boolean distribute(int maxBytes, StreamByteDistributor.Writer writer) throws Http2Exception

Implements io.netty.handler.codec.http2.StreamByteDistributor.distribute.

Doc from io.netty.handler.codec.http2.StreamByteDistributor.distribute.

Distributes up to maxBytes to those streams containing streamable bytes and iterates across those streams to write the appropriate bytes. Criteria for traversing streams is undefined and it is up to the implementation to determine when to stop at a given stream.

The streamable bytes are not automatically updated by calling this method. It is up to the caller to indicate the number of bytes streamable after the write by calling updateStreamableBytes(StreamState).

Parameters
maxBytes:int

the maximum number of bytes to write.

Returns:boolean

true if there are still streamable bytes that have not yet been written, otherwise false.

Annotations
@Override
Exceptions
Http2Exception:
If an internal exception occurs and internal connection state would otherwise be corrupted.
distributeback to summary
private int distribute(int maxBytes, StreamByteDistributor.Writer writer, WeightedFairQueueByteDistributor.State state) throws Http2Exception
distributeToChildrenback to summary
private int distributeToChildren(int maxBytes, StreamByteDistributor.Writer writer, WeightedFairQueueByteDistributor.State state) throws Http2Exception

It is a pre-condition that state.poll() returns a non-null value. This is a result of the way the allocation algorithm is structured and can be explained in the following cases:

For the recursive case

If a stream has no children (in the allocation tree) than that node must be active or it will not be in the allocation tree. If a node is active then it will not delegate to children and recursion ends.

For the initial case

We check connectionState.activeCountForTree == 0 before any allocation is done. So if the connection stream has no active children we don't get into this method.
isChildback to summary
pack-priv boolean isChild(int childId, int parentId, short weight)

For testing only!

notifyParentChangedback to summary
pack-priv void notifyParentChanged(List<WeightedFairQueueByteDistributor.ParentChangedEvent> events)

Notify all listeners of the priority tree change events (in ascending order)

Parameters
events:List<WeightedFairQueueByteDistributor.ParentChangedEvent>

The events (top down order) which have changed

numChildrenback to summary
pack-priv int numChildren(int streamId)

For testing only!

stateback to summary
private WeightedFairQueueByteDistributor.State state(Http2Stream stream)
stateback to summary
private WeightedFairQueueByteDistributor.State state(int streamId)
updateDependencyTreeback to summary
public void updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive)

Implements io.netty.handler.codec.http2.StreamByteDistributor.updateDependencyTree.

Doc from io.netty.handler.codec.http2.StreamByteDistributor.updateDependencyTree.

Explicitly update the dependency tree. This method is called independently of stream state changes.

Parameters
childStreamId:int

The stream identifier associated with the child stream.

parentStreamId:int

The stream identifier associated with the parent stream. May be 0, to make childStreamId and immediate child of the connection.

weight:short

The weight which is used relative to other child streams for parentStreamId. This value must be between 1 and 256 (inclusive).

exclusive:boolean

If childStreamId should be the exclusive dependency of parentStreamId.

Annotations
@Override
updateStreamableBytesback to summary
public void updateStreamableBytes(StreamByteDistributor.StreamState state)

Implements io.netty.handler.codec.http2.StreamByteDistributor.updateStreamableBytes.

Doc from io.netty.handler.codec.http2.StreamByteDistributor.updateStreamableBytes.

Called when the streamable bytes for a stream has changed. Until this method is called for the first time for a give stream, the stream is assumed to have no streamable bytes.

Annotations
@Override
io.netty.handler.codec.http2 back to summary

private final Class WeightedFairQueueByteDistributor.ParentChangedEvent

extends Object
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http2.WeightedFairQueueByteDistributor.ParentChangedEvent

Allows a correlation to be made between a stream and its old parent before a parent change occurs.

Field Summary

Modifier and TypeField and Description
pack-priv final WeightedFairQueueByteDistributor.State
pack-priv final WeightedFairQueueByteDistributor.State

Constructor Summary

AccessConstructor and Description
pack-priv
ParentChangedEvent(WeightedFairQueueByteDistributor.State
The state who has had a parent change.
state
,
WeightedFairQueueByteDistributor.State
The previous parent.
oldParent
)

Create a new instance.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

oldParentback to summary
pack-priv final WeightedFairQueueByteDistributor.State oldParent
stateback to summary
pack-priv final WeightedFairQueueByteDistributor.State state

Constructor Detail

ParentChangedEventback to summary
pack-priv ParentChangedEvent(WeightedFairQueueByteDistributor.State state, WeightedFairQueueByteDistributor.State oldParent)

Create a new instance.

Parameters
state:WeightedFairQueueByteDistributor.State

The state who has had a parent change.

oldParent:WeightedFairQueueByteDistributor.State

The previous parent.

io.netty.handler.codec.http2 back to summary

private final Class WeightedFairQueueByteDistributor.State

extends Object
implements PriorityQueueNode
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http2.WeightedFairQueueByteDistributor.State
All Implemented Interfaces
io.netty.util.internal.PriorityQueueNode

The remote flow control state for a single stream.

Field Summary

Modifier and TypeField and Description
pack-priv int
activeCountForTree

Count of nodes rooted at this sub tree with isActive() equal to true.

pack-priv IntObjectMap<WeightedFairQueueByteDistributor.State>
pack-priv int
private byte
pack-priv WeightedFairQueueByteDistributor.State
pack-priv long
pseudoTime

A pseudo time maintained for immediate children to base their pseudoTimeToWrite off of.

private final PriorityQueue<WeightedFairQueueByteDistributor.State>
private int
pack-priv long
pseudoTimeToWrite

An estimate of when this node should be given the opportunity to write data.

private static final byte
private static final byte
private static final byte
private int
pack-priv Http2Stream
stream

Maybe null if the stream if the stream is not active.

pack-priv int
pack-priv final int
pack-priv long
pack-priv short

Constructor Summary

AccessConstructor and Description
pack-priv
State(int streamId)

pack-priv
pack-priv
State(Http2Stream stream, int initialSize)

pack-priv
State(int streamId, Http2Stream stream, int initialSize)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
activeCountChangeForTree(int increment)

pack-priv void
private long
private void
private void
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv void
offerAndInitializePseudoTime(WeightedFairQueueByteDistributor.State state)

The concept of pseudoTime can be influenced by priority tree manipulations or if a stream goes from "active" to "non-active".

pack-priv void
pack-priv WeightedFairQueueByteDistributor.State
pack-priv WeightedFairQueueByteDistributor.State
pollPseudoTimeQueue()

Must only be called if the pseudoTimeQueue is non-empty!

public int
public void
priorityQueueIndex(DefaultPriorityQueue<?>
The queue for which the index is being set.
queue
,
int
The index as used by DefaultPriorityQueue.
i
)

Implements io.netty.util.internal.PriorityQueueNode.priorityQueueIndex.

Used by DefaultPriorityQueue to maintain state for an element in the queue.
private IntObjectMap<WeightedFairQueueByteDistributor.State>

Returns:

The map of children prior to this operation, excluding streamToRetain if present.
removeAllChildrenExcept
(WeightedFairQueueByteDistributor.State stateToRetain)

Remove all children with the exception of streamToRetain.

pack-priv void
removeChild(WeightedFairQueueByteDistributor.State child)

Removes the child priority and moves any of its dependencies to being direct dependencies on this node.

pack-priv void
private void
pack-priv void
private void
pack-priv void
pack-priv void
pack-priv void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
private void
pack-priv void
pack-priv void
updatePseudoTime(WeightedFairQueueByteDistributor.State parentState, int nsent, long totalQueuedWeights)

Assumes the parents totalQueuedWeights includes this node's weight.

pack-priv void
updateStreamableBytes(int newStreamableBytes, boolean isActive)

pack-priv boolean
pack-priv void
write(int numBytes, StreamByteDistributor.Writer writer)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

activeCountForTreeback to summary
pack-priv int activeCountForTree

Count of nodes rooted at this sub tree with isActive() equal to true.

childrenback to summary
pack-priv IntObjectMap<WeightedFairQueueByteDistributor.State> children
dependencyTreeDepthback to summary
pack-priv int dependencyTreeDepth
flagsback to summary
private byte flags
parentback to summary
pack-priv WeightedFairQueueByteDistributor.State parent
pseudoTimeback to summary
pack-priv long pseudoTime

A pseudo time maintained for immediate children to base their pseudoTimeToWrite off of.

pseudoTimeQueueback to summary
private final PriorityQueue<WeightedFairQueueByteDistributor.State> pseudoTimeQueue
pseudoTimeQueueIndexback to summary
private int pseudoTimeQueueIndex
pseudoTimeToWriteback to summary
pack-priv long pseudoTimeToWrite

An estimate of when this node should be given the opportunity to write data.

STATE_IS_ACTIVEback to summary
private static final byte STATE_IS_ACTIVE
STATE_IS_DISTRIBUTINGback to summary
private static final byte STATE_IS_DISTRIBUTING
STATE_STREAM_ACTIVATEDback to summary
private static final byte STATE_STREAM_ACTIVATED
stateOnlyQueueIndexback to summary
private int stateOnlyQueueIndex
streamback to summary
pack-priv Http2Stream stream

Maybe null if the stream if the stream is not active.

streamableBytesback to summary
pack-priv int streamableBytes
streamIdback to summary
pack-priv final int streamId
totalQueuedWeightsback to summary
pack-priv long totalQueuedWeights
weightback to summary
pack-priv short weight

Constructor Detail

Stateback to summary
pack-priv State(int streamId)
Stateback to summary
pack-priv State(Http2Stream stream)
Stateback to summary
pack-priv State(Http2Stream stream, int initialSize)
Stateback to summary
pack-priv State(int streamId, Http2Stream stream, int initialSize)

Method Detail

activeCountChangeForTreeback to summary
pack-priv void activeCountChangeForTree(int increment)
closeback to summary
pack-priv void close()
getTotalWeightback to summary
private long getTotalWeight()
initChildrenback to summary
private void initChildren()
initChildrenIfEmptyback to summary
private void initChildrenIfEmpty()
isActiveback to summary
pack-priv boolean isActive()
isDescendantOfback to summary
pack-priv boolean isDescendantOf(WeightedFairQueueByteDistributor.State state)
isDistributingback to summary
pack-priv boolean isDistributing()
offerAndInitializePseudoTimeback to summary
pack-priv void offerAndInitializePseudoTime(WeightedFairQueueByteDistributor.State state)

The concept of pseudoTime can be influenced by priority tree manipulations or if a stream goes from "active" to "non-active". This method accounts for that by initializing the pseudoTimeToWrite for state to pseudoTime of this node and then calls offerPseudoTimeQueue(State).

offerPseudoTimeQueueback to summary
pack-priv void offerPseudoTimeQueue(WeightedFairQueueByteDistributor.State state)
peekPseudoTimeQueueback to summary
pack-priv WeightedFairQueueByteDistributor.State peekPseudoTimeQueue()
pollPseudoTimeQueueback to summary
pack-priv WeightedFairQueueByteDistributor.State pollPseudoTimeQueue()

Must only be called if the pseudoTimeQueue is non-empty!

priorityQueueIndexback to summary
public int priorityQueueIndex(DefaultPriorityQueue<?> queue)

Implements io.netty.util.internal.PriorityQueueNode.priorityQueueIndex.

Doc from io.netty.util.internal.PriorityQueueNode.priorityQueueIndex.

Get the last value set by priorityQueueIndex(DefaultPriorityQueue, int) for the value corresponding to queue.

Throwing exceptions from this method will result in undefined behavior.

Annotations
@Override
priorityQueueIndexback to summary
public void priorityQueueIndex(DefaultPriorityQueue<?> queue, int i)

Implements io.netty.util.internal.PriorityQueueNode.priorityQueueIndex.

Doc from io.netty.util.internal.PriorityQueueNode.priorityQueueIndex.

Used by DefaultPriorityQueue to maintain state for an element in the queue.

Throwing exceptions from this method will result in undefined behavior.

Parameters
queue:DefaultPriorityQueue<?>

The queue for which the index is being set.

i:int

The index as used by DefaultPriorityQueue.

Annotations
@Override
removeAllChildrenExceptback to summary
private IntObjectMap<WeightedFairQueueByteDistributor.State> removeAllChildrenExcept(WeightedFairQueueByteDistributor.State stateToRetain)

Remove all children with the exception of streamToRetain. This method is intended to be used to support an exclusive priority dependency operation.

Returns:IntObjectMap<WeightedFairQueueByteDistributor.State>

The map of children prior to this operation, excluding streamToRetain if present.

removeChildback to summary
pack-priv void removeChild(WeightedFairQueueByteDistributor.State child)

Removes the child priority and moves any of its dependencies to being direct dependencies on this node.

removePseudoTimeQueueback to summary
pack-priv void removePseudoTimeQueue(WeightedFairQueueByteDistributor.State state)
setActiveback to summary
private void setActive()
setDistributingback to summary
pack-priv void setDistributing()
setParentback to summary
private void setParent(WeightedFairQueueByteDistributor.State newParent)
setStreamReservedOrActivatedback to summary
pack-priv void setStreamReservedOrActivated()
takeChildback to summary
pack-priv void takeChild(WeightedFairQueueByteDistributor.State child, boolean exclusive, List<WeightedFairQueueByteDistributor.ParentChangedEvent> events)
takeChildback to summary
pack-priv void takeChild(Iterator<IntObjectMap.PrimitiveEntry<WeightedFairQueueByteDistributor.State>> childItr, WeightedFairQueueByteDistributor.State child, boolean exclusive, List<WeightedFairQueueByteDistributor.ParentChangedEvent> events)

Adds a child to this priority. If exclusive is set, any children of this node are moved to being dependent on the child.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
toStringback to summary
private void toString(StringBuilder sb)
unsetActiveback to summary
private void unsetActive()
unsetDistributingback to summary
pack-priv void unsetDistributing()
updatePseudoTimeback to summary
pack-priv void updatePseudoTime(WeightedFairQueueByteDistributor.State parentState, int nsent, long totalQueuedWeights)

Assumes the parents totalQueuedWeights includes this node's weight.

updateStreamableBytesback to summary
pack-priv void updateStreamableBytes(int newStreamableBytes, boolean isActive)
wasStreamReservedOrActivatedback to summary
pack-priv boolean wasStreamReservedOrActivated()
writeback to summary
pack-priv void write(int numBytes, StreamByteDistributor.Writer writer) throws Http2Exception
io.netty.handler.codec.http2 back to summary

private final Class WeightedFairQueueByteDistributor.StateOnlyComparator

extends Object
implements Comparator<WeightedFairQueueByteDistributor.State>, Serializable
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http2.WeightedFairQueueByteDistributor.StateOnlyComparator
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

A comparator for State which has no associated Http2Stream object. The general precedence is:

Field Summary

Modifier and TypeField and Description
pack-priv static final WeightedFairQueueByteDistributor.StateOnlyComparator
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(WeightedFairQueueByteDistributor.State
the first object to be compared.
o1
,
WeightedFairQueueByteDistributor.State
the second object to be compared.
o2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
pack-priv static final WeightedFairQueueByteDistributor.StateOnlyComparator INSTANCE
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

StateOnlyComparatorback to summary
private StateOnlyComparator()

Method Detail

compareback to summary
public int compare(WeightedFairQueueByteDistributor.State o1, WeightedFairQueueByteDistributor.State o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
o1:WeightedFairQueueByteDistributor.State

the first object to be compared.

o2:WeightedFairQueueByteDistributor.State

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override
io.netty.handler.codec.http2 back to summary

private final Class WeightedFairQueueByteDistributor.StatePseudoTimeComparator

extends Object
implements Comparator<WeightedFairQueueByteDistributor.State>, Serializable
Class Inheritance
  • java.lang.Object
  • io.netty.handler.codec.http2.WeightedFairQueueByteDistributor.StatePseudoTimeComparator
All Implemented Interfaces
java.io.Serializable, java.util.Comparator

Field Summary

Modifier and TypeField and Description
pack-priv static final WeightedFairQueueByteDistributor.StatePseudoTimeComparator
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(WeightedFairQueueByteDistributor.State
the first object to be compared.
o1
,
WeightedFairQueueByteDistributor.State
the second object to be compared.
o2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
pack-priv static final WeightedFairQueueByteDistributor.StatePseudoTimeComparator INSTANCE
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

StatePseudoTimeComparatorback to summary
private StatePseudoTimeComparator()

Method Detail

compareback to summary
public int compare(WeightedFairQueueByteDistributor.State o1, WeightedFairQueueByteDistributor.State o2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
o1:WeightedFairQueueByteDistributor.State

the first object to be compared.

o2:WeightedFairQueueByteDistributor.State

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override