|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.apache.hadoop.hbase.io.hadoopbackport.ThrottledInputStream
public class ThrottledInputStream
The ThrottleInputStream provides bandwidth throttling on a specified InputStream. It is implemented as a wrapper on top of another InputStream instance. The throttling works by examining the number of bytes read from the underlying InputStream from the beginning, and sleep()ing for a time interval if the byte-transfer is found exceed the specified tolerable maximum. (Thus, while the read-rate might exceed the maximum for a given short interval, the average tends towards the specified maximum, overall.)
Constructor Summary | |
---|---|
ThrottledInputStream(InputStream rawStream)
|
|
ThrottledInputStream(InputStream rawStream,
long maxBytesPerSec)
|
Method Summary | |
---|---|
void |
close()
|
long |
getBytesPerSec()
Getter for the read-rate from this stream, since creation. |
long |
getTotalBytesRead()
Getter for the number of bytes read from this stream, since creation. |
long |
getTotalSleepTime()
Getter the total time spent in sleep. |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
int |
read(long position,
byte[] buffer,
int offset,
int length)
Read bytes starting from the specified position. |
String |
toString()
|
Methods inherited from class java.io.InputStream |
---|
available, mark, markSupported, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ThrottledInputStream(InputStream rawStream)
public ThrottledInputStream(InputStream rawStream, long maxBytesPerSec)
Method Detail |
---|
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public int read(long position, byte[] buffer, int offset, int length) throws IOException
PositionedReadable
.
position
- buffer
- offset
- length
-
IOException
public long getTotalBytesRead()
public long getBytesPerSec()
public long getTotalSleepTime()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |