Package io.netty.handler.codec.http2
Class WeightedFairQueueByteDistributor.State
- java.lang.Object
-
- io.netty.handler.codec.http2.WeightedFairQueueByteDistributor.State
-
- All Implemented Interfaces:
PriorityQueueNode
- Enclosing class:
- WeightedFairQueueByteDistributor
private final class WeightedFairQueueByteDistributor.State extends java.lang.Object implements PriorityQueueNode
The remote flow control state for a single stream.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
activeCountForTree
Count of nodes rooted at this sub tree withisActive()
equal totrue
.(package private) IntObjectMap<WeightedFairQueueByteDistributor.State>
children
(package private) int
dependencyTreeDepth
private byte
flags
(package private) WeightedFairQueueByteDistributor.State
parent
(package private) long
pseudoTime
A pseudo time maintained for immediate children to base theirpseudoTimeToWrite
off of.private PriorityQueue<WeightedFairQueueByteDistributor.State>
pseudoTimeQueue
private int
pseudoTimeQueueIndex
(package private) long
pseudoTimeToWrite
An estimate of when this node should be given the opportunity to write data.private static byte
STATE_IS_ACTIVE
private static byte
STATE_IS_DISTRIBUTING
private static byte
STATE_STREAM_ACTIVATED
private int
stateOnlyQueueIndex
(package private) Http2Stream
stream
Maybenull
if the stream if the stream is not active.(package private) int
streamableBytes
(package private) int
streamId
(package private) long
totalQueuedWeights
(package private) short
weight
-
Fields inherited from interface io.netty.util.internal.PriorityQueueNode
INDEX_NOT_IN_QUEUE
-
-
Constructor Summary
Constructors Constructor Description State(int streamId)
State(int streamId, Http2Stream stream, int initialSize)
State(Http2Stream stream)
State(Http2Stream stream, int initialSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
activeCountChangeForTree(int increment)
(package private) void
close()
private void
initChildren()
private void
initChildrenIfEmpty()
(package private) boolean
isActive()
(package private) boolean
isDescendantOf(WeightedFairQueueByteDistributor.State state)
(package private) boolean
isDistributing()
(package private) 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".(package private) void
offerPseudoTimeQueue(WeightedFairQueueByteDistributor.State state)
(package private) WeightedFairQueueByteDistributor.State
peekPseudoTimeQueue()
(package private) WeightedFairQueueByteDistributor.State
pollPseudoTimeQueue()
Must only be called if the pseudoTimeQueue is non-empty!int
priorityQueueIndex(DefaultPriorityQueue<?> queue)
Get the last value set byPriorityQueueNode.priorityQueueIndex(DefaultPriorityQueue, int)
for the value corresponding toqueue
.void
priorityQueueIndex(DefaultPriorityQueue<?> queue, int i)
Used byDefaultPriorityQueue
to maintain state for an element in the queue.private IntObjectMap<WeightedFairQueueByteDistributor.State>
removeAllChildrenExcept(WeightedFairQueueByteDistributor.State stateToRetain)
Remove all children with the exception ofstreamToRetain
.(package private) void
removeChild(WeightedFairQueueByteDistributor.State child)
Removes the child priority and moves any of its dependencies to being direct dependencies on this node.(package private) void
removePseudoTimeQueue(WeightedFairQueueByteDistributor.State state)
private void
setActive()
(package private) void
setDistributing()
private void
setParent(WeightedFairQueueByteDistributor.State newParent)
(package private) void
setStreamReservedOrActivated()
(package private) void
takeChild(WeightedFairQueueByteDistributor.State child, boolean exclusive, java.util.List<WeightedFairQueueByteDistributor.ParentChangedEvent> events)
(package private) void
takeChild(java.util.Iterator<IntObjectMap.PrimitiveEntry<WeightedFairQueueByteDistributor.State>> childItr, WeightedFairQueueByteDistributor.State child, boolean exclusive, java.util.List<WeightedFairQueueByteDistributor.ParentChangedEvent> events)
Adds a child to this priority.java.lang.String
toString()
private void
toString(java.lang.StringBuilder sb)
private void
unsetActive()
(package private) void
unsetDistributing()
(package private) void
updatePseudoTime(WeightedFairQueueByteDistributor.State parentState, int nsent, long totalQueuedWeights)
Assumes the parentstotalQueuedWeights
includes this node's weight.(package private) void
updateStreamableBytes(int newStreamableBytes, boolean isActive)
(package private) boolean
wasStreamReservedOrActivated()
(package private) void
write(int numBytes, StreamByteDistributor.Writer writer)
-
-
-
Field Detail
-
STATE_IS_ACTIVE
private static final byte STATE_IS_ACTIVE
- See Also:
- Constant Field Values
-
STATE_IS_DISTRIBUTING
private static final byte STATE_IS_DISTRIBUTING
- See Also:
- Constant Field Values
-
STATE_STREAM_ACTIVATED
private static final byte STATE_STREAM_ACTIVATED
- See Also:
- Constant Field Values
-
stream
Http2Stream stream
Maybenull
if the stream if the stream is not active.
-
parent
WeightedFairQueueByteDistributor.State parent
-
children
IntObjectMap<WeightedFairQueueByteDistributor.State> children
-
pseudoTimeQueue
private final PriorityQueue<WeightedFairQueueByteDistributor.State> pseudoTimeQueue
-
streamId
final int streamId
-
streamableBytes
int streamableBytes
-
dependencyTreeDepth
int dependencyTreeDepth
-
activeCountForTree
int activeCountForTree
Count of nodes rooted at this sub tree withisActive()
equal totrue
.
-
pseudoTimeQueueIndex
private int pseudoTimeQueueIndex
-
stateOnlyQueueIndex
private int stateOnlyQueueIndex
-
pseudoTimeToWrite
long pseudoTimeToWrite
An estimate of when this node should be given the opportunity to write data.
-
pseudoTime
long pseudoTime
A pseudo time maintained for immediate children to base theirpseudoTimeToWrite
off of.
-
totalQueuedWeights
long totalQueuedWeights
-
flags
private byte flags
-
weight
short weight
-
-
Constructor Detail
-
State
State(int streamId)
-
State
State(Http2Stream stream)
-
State
State(Http2Stream stream, int initialSize)
-
State
State(int streamId, Http2Stream stream, int initialSize)
-
-
Method Detail
-
isDescendantOf
boolean isDescendantOf(WeightedFairQueueByteDistributor.State state)
-
takeChild
void takeChild(WeightedFairQueueByteDistributor.State child, boolean exclusive, java.util.List<WeightedFairQueueByteDistributor.ParentChangedEvent> events)
-
takeChild
void takeChild(java.util.Iterator<IntObjectMap.PrimitiveEntry<WeightedFairQueueByteDistributor.State>> childItr, WeightedFairQueueByteDistributor.State child, boolean exclusive, java.util.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.
-
removeChild
void removeChild(WeightedFairQueueByteDistributor.State child)
Removes the child priority and moves any of its dependencies to being direct dependencies on this node.
-
removeAllChildrenExcept
private IntObjectMap<WeightedFairQueueByteDistributor.State> removeAllChildrenExcept(WeightedFairQueueByteDistributor.State stateToRetain)
Remove all children with the exception ofstreamToRetain
. This method is intended to be used to support an exclusive priority dependency operation.- Returns:
- The map of children prior to this operation, excluding
streamToRetain
if present.
-
setParent
private void setParent(WeightedFairQueueByteDistributor.State newParent)
-
initChildrenIfEmpty
private void initChildrenIfEmpty()
-
initChildren
private void initChildren()
-
write
void write(int numBytes, StreamByteDistributor.Writer writer) throws Http2Exception
- Throws:
Http2Exception
-
activeCountChangeForTree
void activeCountChangeForTree(int increment)
-
updateStreamableBytes
void updateStreamableBytes(int newStreamableBytes, boolean isActive)
-
updatePseudoTime
void updatePseudoTime(WeightedFairQueueByteDistributor.State parentState, int nsent, long totalQueuedWeights)
Assumes the parentstotalQueuedWeights
includes this node's weight.
-
offerAndInitializePseudoTime
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 thepseudoTimeToWrite
forstate
topseudoTime
of this node and then callsofferPseudoTimeQueue(State)
.
-
offerPseudoTimeQueue
void offerPseudoTimeQueue(WeightedFairQueueByteDistributor.State state)
-
pollPseudoTimeQueue
WeightedFairQueueByteDistributor.State pollPseudoTimeQueue()
Must only be called if the pseudoTimeQueue is non-empty!
-
removePseudoTimeQueue
void removePseudoTimeQueue(WeightedFairQueueByteDistributor.State state)
-
peekPseudoTimeQueue
WeightedFairQueueByteDistributor.State peekPseudoTimeQueue()
-
close
void close()
-
wasStreamReservedOrActivated
boolean wasStreamReservedOrActivated()
-
setStreamReservedOrActivated
void setStreamReservedOrActivated()
-
isActive
boolean isActive()
-
setActive
private void setActive()
-
unsetActive
private void unsetActive()
-
isDistributing
boolean isDistributing()
-
setDistributing
void setDistributing()
-
unsetDistributing
void unsetDistributing()
-
priorityQueueIndex
public int priorityQueueIndex(DefaultPriorityQueue<?> queue)
Description copied from interface:PriorityQueueNode
Get the last value set byPriorityQueueNode.priorityQueueIndex(DefaultPriorityQueue, int)
for the value corresponding toqueue
.Throwing exceptions from this method will result in undefined behavior.
- Specified by:
priorityQueueIndex
in interfacePriorityQueueNode
-
priorityQueueIndex
public void priorityQueueIndex(DefaultPriorityQueue<?> queue, int i)
Description copied from interface:PriorityQueueNode
Used byDefaultPriorityQueue
to maintain state for an element in the queue.Throwing exceptions from this method will result in undefined behavior.
- Specified by:
priorityQueueIndex
in interfacePriorityQueueNode
- Parameters:
queue
- The queue for which the index is being set.i
- The index as used byDefaultPriorityQueue
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toString
private void toString(java.lang.StringBuilder sb)
-
-