org.jumpmind.symmetric.util
Class MeteredOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.jumpmind.symmetric.util.MeteredOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
public class MeteredOutputStream
- extends java.io.FilterOutputStream
Throttle output stream to write at a specified rate. the rate will be an
average
- Author:
- hwang
| Fields inherited from class java.io.FilterOutputStream |
out |
|
Method Summary |
void |
write(int b)
|
| Methods inherited from class java.io.FilterOutputStream |
close, flush, write, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MeteredOutputStream
public MeteredOutputStream(java.io.OutputStream out,
long maxBps,
long threshold)
- Parameters:
out - stream written tomaxBps - max number of bytes per secondthreshold - the number in bytes before the throttle output stream
MeteredOutputStream
public MeteredOutputStream(java.io.OutputStream out,
long maxBps,
long threshold,
long checkPoint)
- Parameters:
out - out stream written tomaxBps - max number of bytes per secondthreshold - the number in bytes before throttling output streamcheckPoint - check the average rate when total byts%checkPoint == 0.
the throttled output stream will write checkPoing number
of bytes at full speed, and then sleep for a certain to
obtain an average close to maxBps. If set it to 1, it will
check every bytes written and the rate will be the most
accurate.
MeteredOutputStream
public MeteredOutputStream(java.io.OutputStream out,
long maxBps)
- Parameters:
out - maxBps -
write
public void write(int b)
throws java.io.IOException
- Overrides:
write in class java.io.FilterOutputStream
- Throws:
java.io.IOException
Copyright © 2007-2008. All Rights Reserved.