com.sun.faban.driver.transport.util
Class Throttle

java.lang.Object
  extended by com.sun.faban.driver.transport.util.Throttle

public class Throttle
extends Object

A helper class to provide throttling on sockets

Author:
Scott Oaks

Field Summary
static int DOWN
           
static int UP
           
 
Constructor Summary
Throttle(DriverContext ctx)
          Constructs a throttle.
 
Method Summary
 boolean isThrottled(int direction)
          Checks whether the bandwidth is throttled for the given direction
 void throttle(int bytes, long startTime, int direction)
          The throttle sleeps until the calculated time for the request has expired, before continuing with subsequent I/O.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UP

public static final int UP
See Also:
Constant Field Values

DOWN

public static final int DOWN
See Also:
Constant Field Values
Constructor Detail

Throttle

public Throttle(DriverContext ctx)
Constructs a throttle.

Parameters:
ctx - The driver context
Method Detail

isThrottled

public boolean isThrottled(int direction)
Checks whether the bandwidth is throttled for the given direction

Parameters:
direction - The direction to check
Returns:
Whether the bandwidth is throttled

throttle

public void throttle(int bytes,
                     long startTime,
                     int direction)
The throttle sleeps until the calculated time for the request has expired, before continuing with subsequent I/O.

Parameters:
bytes - The size of the data sent/received
startTime - The start time of the send/receive
direction - The direction, up or down