org.apache.blur.lucene.warmup
Class ThrottledIndexInput
java.lang.Object
org.apache.lucene.store.DataInput
org.apache.lucene.store.IndexInput
org.apache.blur.lucene.warmup.ThrottledIndexInput
- All Implemented Interfaces:
- Closeable, Cloneable
public class ThrottledIndexInput
- extends org.apache.lucene.store.IndexInput
This class has been derived from the
org.apache.hadoop.tools.util.ThrottledInputStream class found in Hadoop.
The ThrottledIndexInput provides bandwidth throttling on a specified
IndexInput. It is implemented as a wrapper on top of another IndexInput
instance. The throttling works by examining the number of bytes read from the
underlying IndexInput 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 |
ThrottledIndexInput(org.apache.lucene.store.IndexInput rawStream,
long maxBytesPerSec)
|
ThrottledIndexInput(org.apache.lucene.store.IndexInput rawStream,
long maxBytesPerSec,
long bytesRead,
long totalSleepTime,
long startTime)
|
Methods inherited from class org.apache.lucene.store.IndexInput |
clone |
Methods inherited from class org.apache.lucene.store.DataInput |
readBytes, readInt, readLong, readShort, readString, readStringSet, readStringStringMap, readVInt, readVLong |
ThrottledIndexInput
public ThrottledIndexInput(org.apache.lucene.store.IndexInput rawStream,
long maxBytesPerSec)
ThrottledIndexInput
public ThrottledIndexInput(org.apache.lucene.store.IndexInput rawStream,
long maxBytesPerSec,
long bytesRead,
long totalSleepTime,
long startTime)
getFilePointer
public long getFilePointer()
- Specified by:
getFilePointer
in class org.apache.lucene.store.IndexInput
seek
public void seek(long pos)
throws IOException
- Specified by:
seek
in class org.apache.lucene.store.IndexInput
- Throws:
IOException
length
public long length()
- Specified by:
length
in class org.apache.lucene.store.IndexInput
readByte
public byte readByte()
throws IOException
- Specified by:
readByte
in class org.apache.lucene.store.DataInput
- Throws:
IOException
readBytes
public void readBytes(byte[] b,
int offset,
int len)
throws IOException
- Specified by:
readBytes
in class org.apache.lucene.store.DataInput
- Throws:
IOException
close
public void close()
throws IOException
- Specified by:
close
in interface Closeable
- Specified by:
close
in class org.apache.lucene.store.IndexInput
- Throws:
IOException
getTotalBytesRead
public long getTotalBytesRead()
- Getter for the number of bytes read from this stream, since creation.
- Returns:
- The number of bytes.
getBytesPerSec
public double getBytesPerSec()
- Getter for the read-rate from this stream, since creation. Calculated as
bytesRead/elapsedTimeSinceStart.
- Returns:
- Read rate, in bytes/sec.
getTotalSleepTime
public long getTotalSleepTime()
- Getter the total time spent in sleep.
- Returns:
- Number of milliseconds spent in sleep.
toString
public String toString()
- Overrides:
toString
in class org.apache.lucene.store.IndexInput
getStartTime
public long getStartTime()
Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.