/** * Resisters a stream, with its dependency and dependent information * @param streamId The stream id * @param dependency The stream this stream depends on, if no stream is specified this should be zero * @param weighting The weighting. If no weighting is specified this should be 16 */ public void registerStream(int streamId, int dependency, int weighting, boolean exclusive) { final Http2PriorityNode node = new Http2PriorityNode(streamId, weighting); if(exclusive) { Http2PriorityNode existing = nodesByID.get(dependency); if(existing != null) { existing.exclusive(node); } } else { Http2PriorityNode existing = nodesByID.get(dependency); if(existing != null) { existing.addDependent(node); } } nodesByID.put(streamId, node); }
/** * Method that is invoked when a stream has been removed * * @param streamId id of the stream removed */ public void streamRemoved(int streamId) { Http2PriorityNode node = nodesByID.get(streamId); if(node == null) { return; } if(!node.hasDependents()) { //add to eviction queue int toEvict = evictionQueue[evictionQueuePosition]; evictionQueue[evictionQueuePosition++] = streamId; Http2PriorityNode nodeToEvict = nodesByID.get(toEvict); //we don't remove the node if it has since got dependents since it was put into the queue //as this is the whole reason we maintain the queue in the first place if(nodeToEvict != null && !nodeToEvict.hasDependents()) { nodesByID.remove(toEvict); } } }
public void priorityFrame(int streamId, int streamDependency, int weight, boolean exlusive) { Http2PriorityNode existing = nodesByID.get(streamId); if(existing == null) { return; } int dif = weight - existing.weighting; existing.parent.totalWeights += dif; existing.weighting = weight; if(exlusive) { Http2PriorityNode newParent = nodesByID.get(streamDependency); if(newParent != null) { existing.parent.removeDependent(existing); newParent.exclusive(existing); } } else if(existing.parent.streamId != streamDependency) { Http2PriorityNode newParent = nodesByID.get(streamDependency); if(newParent != null) { newParent.addDependent(existing); } } }
/** * Method that is invoked when a stream has been removed * * @param streamId id of the stream removed */ public void streamRemoved(int streamId) { Http2PriorityNode node = nodesByID.get(streamId); if(node == null) { return; } if(!node.hasDependents()) { //add to eviction queue int toEvict = evictionQueue[evictionQueuePosition]; evictionQueue[evictionQueuePosition++] = streamId; Http2PriorityNode nodeToEvict = nodesByID.get(toEvict); //we don't remove the node if it has since got dependents since it was put into the queue //as this is the whole reason we maintain the queue in the first place if(nodeToEvict != null && !nodeToEvict.hasDependents()) { nodesByID.remove(toEvict); } } }
/** * Resisters a stream, with its dependency and dependent information * @param streamId The stream id * @param dependency The stream this stream depends on, if no stream is specified this should be zero * @param weighting The weighting. If no weighting is specified this should be 16 */ public void registerStream(int streamId, int dependency, int weighting, boolean exclusive) { final Http2PriorityNode node = new Http2PriorityNode(streamId, weighting); if(exclusive) { Http2PriorityNode existing = nodesByID.get(dependency); if(existing != null) { existing.exclusive(node); } } else { Http2PriorityNode existing = nodesByID.get(dependency); if(existing != null) { existing.addDependent(node); } } nodesByID.put(streamId, node); }
public void priorityFrame(int streamId, int streamDependency, int weight, boolean exlusive) { Http2PriorityNode existing = nodesByID.get(streamId); if(existing == null) { return; } int dif = weight - existing.weighting; existing.parent.totalWeights += dif; existing.weighting = weight; if(exlusive) { Http2PriorityNode newParent = nodesByID.get(streamDependency); if(newParent != null) { existing.parent.removeDependent(existing); newParent.exclusive(existing); } } else if(existing.parent.streamId != streamDependency) { Http2PriorityNode newParent = nodesByID.get(streamDependency); if(newParent != null) { newParent.addDependent(existing); } } }
public void priorityFrame(int streamId, int streamDependency, int weight, boolean exlusive) { Http2PriorityNode existing = nodesByID.get(streamId); if(existing == null) { return; } int dif = weight - existing.weighting; existing.parent.totalWeights += dif; existing.weighting = weight; if(exlusive) { Http2PriorityNode newParent = nodesByID.get(streamDependency); if(newParent != null) { existing.parent.removeDependent(existing); newParent.exclusive(existing); } } else if(existing.parent.streamId != streamDependency) { Http2PriorityNode newParent = nodesByID.get(streamDependency); if(newParent != null) { newParent.addDependent(existing); } } }
public void exclusive(Http2PriorityNode node) { if(dependents == null) { dependents = new Http2PriorityNode[5]; } for(Http2PriorityNode i : dependents) { if(i != null) { node.addDependent(i); } } dependents[0] = node; for(int i = 1; i < dependents.length; ++ i) { dependents[i] = null; } totalWeights = node.weighting; } }
/** * Method that is invoked when a stream has been removed * * @param streamId id of the stream removed */ public void streamRemoved(int streamId) { Http2PriorityNode node = nodesByID.get(streamId); if(node == null) { return; } if(!node.hasDependents()) { //add to eviction queue int toEvict = evictionQueue[evictionQueuePosition]; evictionQueue[evictionQueuePosition++] = streamId; Http2PriorityNode nodeToEvict = nodesByID.get(toEvict); //we don't remove the node if it has since got dependents since it was put into the queue //as this is the whole reason we maintain the queue in the first place if(nodeToEvict != null && !nodeToEvict.hasDependents()) { nodesByID.remove(toEvict); } } }
/** * Resisters a stream, with its dependency and dependent information * @param streamId The stream id * @param dependency The stream this stream depends on, if no stream is specified this should be zero * @param weighting The weighting. If no weighting is specified this should be 16 */ public void registerStream(int streamId, int dependency, int weighting, boolean exclusive) { final Http2PriorityNode node = new Http2PriorityNode(streamId, weighting); if(exclusive) { Http2PriorityNode existing = nodesByID.get(dependency); if(existing != null) { existing.exclusive(node); } } else { Http2PriorityNode existing = nodesByID.get(dependency); if(existing != null) { existing.addDependent(node); } } nodesByID.put(streamId, node); }
public void exclusive(Http2PriorityNode node) { if(dependents == null) { dependents = new Http2PriorityNode[5]; } for(Http2PriorityNode i : dependents) { if(i != null) { node.addDependent(i); } } dependents[0] = node; for(int i = 1; i < dependents.length; ++ i) { dependents[i] = null; } totalWeights = node.weighting; } }
/** * The maximum number of streams that we store priority information for */ public Http2PriorityTree() { this.rootNode = new Http2PriorityNode(0, 0); nodesByID.put(0, this.rootNode); this.evictionQueue = new int[10]; //todo: make this size customisable }
/** * The maximum number of streams that we store priority information for */ public Http2PriorityTree() { this.rootNode = new Http2PriorityNode(0, 0); nodesByID.put(0, this.rootNode); this.evictionQueue = new int[10]; //todo: make this size customisable }
public void exclusive(Http2PriorityNode node) { if(dependents == null) { dependents = new Http2PriorityNode[5]; } for(Http2PriorityNode i : dependents) { if(i != null) { node.addDependent(i); } } dependents[0] = node; for(int i = 1; i < dependents.length; ++ i) { dependents[i] = null; } totalWeights = node.weighting; } }
/** * The maximum number of streams that we store priority information for */ public Http2PriorityTree() { this.rootNode = new Http2PriorityNode(0, 0); nodesByID.put(0, this.rootNode); this.evictionQueue = new int[10]; //todo: make this size customisable }