public class TrafficShaping
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
algorithm |
static int |
LEAKY_BUCKET |
private LeakyBucket |
leakyBucket |
static int |
NONE |
static int |
TOKEN_BUCKET |
private TokenBucket |
tokenBucket |
Constructor and Description |
---|
TrafficShaping(long capacity,
long rate,
int algorithm) |
Modifier and Type | Method and Description |
---|---|
static float |
calculateAverageWeighted(long[] bytes,
long[] times)
Calculates the average of bytes per second.
|
int |
getTokens(int length) |
void |
list(java.io.PrintStream out)
Prints this HTTP Request Reader fields out to the
specified output stream.
|
java.lang.String |
toString() |
private TokenBucket tokenBucket
private LeakyBucket leakyBucket
private int algorithm
public static final int NONE
public static final int TOKEN_BUCKET
public static final int LEAKY_BUCKET
public TrafficShaping(long capacity, long rate, int algorithm)
capacity
- rate
- algorithm
- public int getTokens(int length)
numTokens
- public java.lang.String toString()
toString
in class java.lang.Object
public void list(java.io.PrintStream out)
out
- an output stream.public static float calculateAverageWeighted(long[] bytes, long[] times)
bytes
- is an one-dimensional array with the amount of bytes.times
- is an one-dimensional array with the time where bytes
was sent. It is expressed in miliseconds. The first index is
when the first dada was sent, and the last one is the most
most recently time.
CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Group on Interactive Coding of Images (GICI) (contact)