org.jboss.netty.channel
Class AdaptiveReceiveBufferSizePredictor

java.lang.Object
  extended by org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictor
All Implemented Interfaces:
ReceiveBufferSizePredictor

public class AdaptiveReceiveBufferSizePredictor
extends Object
implements ReceiveBufferSizePredictor

The ReceiveBufferSizePredictor that automatically increases and decreases the predicted buffer size on feed back.

It gradually increases the expected number of readable bytes if the previous read fully filled the allocated buffer. It gradually decreases the expected number of readable bytes if the read operation was not able to fill a certain amount of the allocated buffer two times consecutively. Otherwise, it keeps returning the same prediction.

Version:
$Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
Author:
The Netty Project, Trustin Lee

Constructor Summary
AdaptiveReceiveBufferSizePredictor()
          Creates a new predictor with the default parameters.
AdaptiveReceiveBufferSizePredictor(int minimum, int initial, int maximum)
          Creates a new predictor with the specified parameters.
 
Method Summary
 int nextReceiveBufferSize()
          Predicts the capacity of the ChannelBuffer for the next read operation depending on the actual number of read bytes in the previous read operation.
 void previousReceiveBufferSize(int previousReceiveBufferSize)
          Updates this predictor by specifying the actual number of read bytes in the previous read operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdaptiveReceiveBufferSizePredictor

public AdaptiveReceiveBufferSizePredictor()
Creates a new predictor with the default parameters. With the default parameters, the expected buffer size starts from 1024, does not go down below 64, and does not go up above 65536.


AdaptiveReceiveBufferSizePredictor

public AdaptiveReceiveBufferSizePredictor(int minimum,
                                          int initial,
                                          int maximum)
Creates a new predictor with the specified parameters.

Parameters:
minimum - the inclusive lower bound of the expected buffer size
initial - the initial buffer size when no feed back was received
maximum - the inclusive upper bound of the expected buffer size
Method Detail

nextReceiveBufferSize

public int nextReceiveBufferSize()
Description copied from interface: ReceiveBufferSizePredictor
Predicts the capacity of the ChannelBuffer for the next read operation depending on the actual number of read bytes in the previous read operation.

Specified by:
nextReceiveBufferSize in interface ReceiveBufferSizePredictor
Returns:
the expected number of readable bytes this time

previousReceiveBufferSize

public void previousReceiveBufferSize(int previousReceiveBufferSize)
Description copied from interface: ReceiveBufferSizePredictor
Updates this predictor by specifying the actual number of read bytes in the previous read operation.

Specified by:
previousReceiveBufferSize in interface ReceiveBufferSizePredictor
Parameters:
previousReceiveBufferSize - the actual number of read bytes in the previous read operation


Copyright © 2008-2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.