|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.OutputStream | +--java.io.FilterOutputStream | +--gausssoft.io.StatusOutputStream | +--gausssoft.io.ChunkingOutputStream | +--gausssoft.io.BandwidthOutputStream
This class measures the level of throughput that goes into an underlying OutputStream
.
This implementation uses the ChunkingOutputStream
class to perform updates.
It is recommended that you look at how the ChunkingOutputStream
class
works before using this class.
The bandwidth is calculated every time an interrupt is performed. It is necessary to
call the initiate()
method to begin measuring throughput. You can also
call the resetMeasuring()
to discard previous bandwidth calculations.
Bandwidth is calculated by taking the number of bytes passed since the initiate
or
resetMeasuring
was last called. Bandwidth is calculated in bytes per second.
When the stream is closed, the bandwidth at that point is calculated, and is subsequently
returned every time getBandwidth()
is invoked.
BandwidthInputStream
Fields inherited from class java.io.FilterOutputStream |
out |
Constructor Summary | |
|
BandwidthOutputStream(OutputStream out)
Creates a BandwidthOutputStream that does not use cumulative totals, chunks data into 1024 bytes, and performs start-of-call and end-of-call interrupts. |
|
BandwidthOutputStream(OutputStream out,
int chunksize)
Creates a BandwidthOutputStream that does not use cumulative totals, and performs start-of-call and end-of-call interrupts. |
protected |
BandwidthOutputStream(OutputStream out,
int chunksize,
boolean cumulative,
boolean start)
Creates a BandwidthOutputStream that performs end-of-call interrupts. |
Method Summary | |
void |
close()
|
int |
getBandwidth()
Calculates the bandwidth in bytes per second. |
void |
initiate()
Begins measuring bandwidth. |
boolean |
initiated()
Indicates if this stream has been initiated yet. |
protected void |
interrupt()
Used for bandwidth calculations. |
void |
resetMeasuring()
Discards all previous calculation data. |
Methods inherited from class gausssoft.io.ChunkingOutputStream |
getChunkSize, setChunkSize, updateChunkSize, write, write, write |
Methods inherited from class gausssoft.io.StatusOutputStream |
flush, getCount, isClosed |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BandwidthOutputStream(OutputStream out)
initiate()
method must be called to begin measuring.out
- The OutputStream to wrap around.NullPointerException
- If in
is null
.public BandwidthOutputStream(OutputStream out, int chunksize)
initiate()
method must be called to begin measuring.out
- The OutputStream to wrap around.chunksize
- The chunk size to use.NullPointerException
- If in
is null
.IllegalArgumentException
- If chunksize
is less than 1.protected BandwidthOutputStream(OutputStream out, int chunksize, boolean cumulative, boolean start)
initiate()
method must be called to begin measuring.out
- The OutputStream to wrap around.chunksize
- The chunk size to use.cumulative
- true
if this object should use the getCount
method
for calculations, false
to use an internal counter.start
- true
if this object should perform start-of-call interrupts.NullPointerException
- If in
is null
.IllegalArgumentException
- If chunksize
is less than 1.Method Detail |
public void initiate()
resetMeasuring()
,
initiated()
protected void interrupt()
interrupt
in class ChunkingOutputStream
ChunkingOutputStream.interrupt()
public final boolean initiated()
true
if this stream has been initiated.initiate()
public final void resetMeasuring()
public final int getBandwidth()
IllegalStateException
- If this method is invoked before the object is initialised.public void close() throws IOException
close
in class StatusOutputStream
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |