All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.io.OutputStream | +----java.io.FilterOutputStream | +----Acme.Serve.ThrottledOutputStream
Restricts output to a specified rate. Also includes a static utility routine for parsing a file of throttle settings.
Fetch the software.
Fetch the entire Acme package.
public ThrottledOutputStream(OutputStream out, long maxBps)
public static WildcardDictionary parseThrottleFile(String filename) throws IOException
A throttle file lets you set maximum byte rates on filename patterns. The format of the throttle file is very simple. A # starts a comment, and the rest of the line is ignored. Blank lines are ignored. The rest of the lines should consist of a pattern, whitespace, and a number. The pattern is a simple shell-style filename pattern, using ? and *, or multiple such patterns separated by |.
The numbers in the file are byte rates, specified in units of bytes per second. For comparison, a v.32b/v.42b modem gives about 1500/2000 B/s depending on compression, a double-B-channel ISDN line about 12800 B/s, and a T1 line is about 150000 B/s.
Example:
# throttle file for www.acme.com * 100000 # limit total web usage to 2/3 of our T1 *.jpg|*.gif 50000 # limit images to 1/3 of our T1 *.mpg 20000 # and movies to even less jef/* 20000 # jef's pages are too popular
The routine returns a WildcardDictionary. Do a lookup in this dictionary using a filename, and you'll get back a ThrottleItem containing the corresponding byte rate.
public void write(int b) throws IOException
public void write(byte b[], int off, int len) throws IOException
All Packages Class Hierarchy This Package Previous Next Index
ACME Java ACME Labs