private static Log log = LogFactory.getInstance().getLog("firefly-system");
@Test
public void testAdaptive() {
ReceiveBufferSizePredictor receiveBufferSizePredictor = new AdaptiveReceiveBufferSizePredictor();
receiveBufferSizePredictor.previousReceiveBufferSize(960);
receiveBufferSizePredictor.previousReceiveBufferSize(960);
receiveBufferSizePredictor.previousReceiveBufferSize(960);
log.debug("current buf size: " + receiveBufferSizePredictor.nextReceiveBufferSize());
Assert.assertThat(receiveBufferSizePredictor.nextReceiveBufferSize(), is(1024));
receiveBufferSizePredictor.previousReceiveBufferSize(1025);
receiveBufferSizePredictor.previousReceiveBufferSize(1300);
log.debug("current buf size: " + receiveBufferSizePredictor.nextReceiveBufferSize());
Assert.assertThat(receiveBufferSizePredictor.nextReceiveBufferSize(), greaterThan(1024));
receiveBufferSizePredictor.previousReceiveBufferSize(4000);
log.debug("current buf size: " + receiveBufferSizePredictor.nextReceiveBufferSize());
Assert.assertThat(receiveBufferSizePredictor.nextReceiveBufferSize(), greaterThan(2000));
receiveBufferSizePredictor.previousReceiveBufferSize(500);
Assert.assertThat(receiveBufferSizePredictor.nextReceiveBufferSize(), greaterThan(2000));
receiveBufferSizePredictor.previousReceiveBufferSize(1000);
Assert.assertThat(receiveBufferSizePredictor.nextReceiveBufferSize(), lessThan(2000));
}