@Test public void writeShouldFavorPriority() throws Http2Exception { setPriority(STREAM_A, 0, (short) 50, false); setPriority(STREAM_B, 0, (short) 200, false); setPriority(STREAM_C, 0, (short) 100, false); setPriority(STREAM_D, 0, (short) 100, false); initState(STREAM_A, 1000, true); initState(STREAM_B, 1000, true); initState(STREAM_C, 1000, false); initState(STREAM_D, 1000, false); distributor.allocationQuantum(1); assertTrue(write(100)); assertEquals(20, captureWrites(STREAM_A)); verifyWrite(times(20), STREAM_A, 1); assertEquals(80, captureWrites(STREAM_B)); verifyWrite(times(0), STREAM_B, 1); verifyNeverWrite(STREAM_C); verifyNeverWrite(STREAM_D); assertTrue(write(100)); assertEquals(40, captureWrites(STREAM_A)); verifyWrite(times(40), STREAM_A, 1); assertEquals(160, captureWrites(STREAM_B)); verifyWrite(atMost(1), STREAM_B, 1); verifyNeverWrite(STREAM_C); verifyNeverWrite(STREAM_D); assertTrue(write(1050)); assertEquals(250, captureWrites(STREAM_A)); verifyWrite(times(250), STREAM_A, 1); assertEquals(1000, captureWrites(STREAM_B)); verifyWrite(atMost(2), STREAM_B, 1); verifyNeverWrite(STREAM_C); verifyNeverWrite(STREAM_D); assertFalse(write(750)); assertEquals(1000, captureWrites(STREAM_A)); verifyWrite(times(1), STREAM_A, 750); assertEquals(1000, captureWrites(STREAM_B)); verifyWrite(times(0), STREAM_B, 0); verifyNeverWrite(STREAM_C); verifyNeverWrite(STREAM_D); }
public void allocationQuantum(int allocationQuantum) { if (allocationQuantum <= 0) { throw new IllegalArgumentException("allocationQuantum must be > 0"); } this.allocationQuantum = allocationQuantum; }
WeightedFairQueueByteDistributor implements StreamByteDistributor { public void allocationQuantum(int allocationQuantum) { if (allocationQuantum <= 0) { throw new IllegalArgumentException("allocationQuantum must be > 0"); } this.allocationQuantum = allocationQuantum; } }
WeightedFairQueueByteDistributor implements StreamByteDistributor { public void allocationQuantum(int allocationQuantum) { if (allocationQuantum <= 0) { throw new IllegalArgumentException("allocationQuantum must be > 0"); } this.allocationQuantum = allocationQuantum; } WeightedFairQueueByteDistributor(Http2Connection connection);  WeightedFairQueueByteDistributor(Http2Connection connection, int maxStateOnlySize); }
WeightedFairQueueByteDistributor implements StreamByteDistributor { public void allocationQuantum(int allocationQuantum) { if (allocationQuantum <= 0) { throw new IllegalArgumentException("allocationQuantum must be > 0"); } this.allocationQuantum = allocationQuantum; } WeightedFairQueueByteDistributor(Http2Connection connection);  WeightedFairQueueByteDistributor(Http2Connection connection, int maxStateOnlySize); @Override void updateStreamableBytes(StreamState state); @Override void updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive); @Override boolean distribute(int maxBytes, Writer writer); void allocationQuantum(int allocationQuantum); }
WeightedFairQueueByteDistributor implements StreamByteDistributor { public void allocationQuantum(int allocationQuantum) { if (allocationQuantum <= 0) { throw new IllegalArgumentException("allocationQuantum must be > 0"); } this.allocationQuantum = allocationQuantum; } WeightedFairQueueByteDistributor(Http2Connection connection);  WeightedFairQueueByteDistributor(Http2Connection connection, int maxStateOnlySize); @Override void updateStreamableBytes(StreamState state); @Override void updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive); @Override boolean distribute(int maxBytes, Writer writer); void allocationQuantum(int allocationQuantum);  }