Package org.apache.cassandra.io.util
Class LimitingRebufferer
- java.lang.Object
-
- org.apache.cassandra.io.util.WrappingRebufferer
-
- org.apache.cassandra.io.util.LimitingRebufferer
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,ReaderFileProxy
,Rebufferer
,Rebufferer.BufferHolder
@NotThreadSafe public class LimitingRebufferer extends WrappingRebufferer
Rebufferer wrapper that applies rate limiting.Instantiated once per RandomAccessReader, thread-unsafe. The instances reuse themselves as the BufferHolder to avoid having to return a new object for each rebuffer call. Only one BufferHolder can be active at a time. Calling
rebuffer(long)
before the previously obtained buffer holder is released will throwAssertionError
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.cassandra.io.util.Rebufferer
Rebufferer.BufferHolder
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.io.util.WrappingRebufferer
buffer, bufferHolder, offset, wrapped
-
Fields inherited from interface org.apache.cassandra.io.util.Rebufferer
EMPTY
-
-
Constructor Summary
Constructors Constructor Description LimitingRebufferer(Rebufferer wrapped, com.google.common.util.concurrent.RateLimiter limiter, int limitQuant)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rebufferer.BufferHolder
rebuffer(long position)
Rebuffer (move on or seek to) a given position, and return a buffer that can be used there.java.lang.String
toString()
-
Methods inherited from class org.apache.cassandra.io.util.WrappingRebufferer
buffer, channel, close, closeReader, fileLength, getCrcCheckChance, offset, release
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.io.util.Rebufferer.BufferHolder
floatBuffer, intBuffer
-
-
-
-
Constructor Detail
-
LimitingRebufferer
public LimitingRebufferer(Rebufferer wrapped, com.google.common.util.concurrent.RateLimiter limiter, int limitQuant)
-
-
Method Detail
-
rebuffer
public Rebufferer.BufferHolder rebuffer(long position)
Description copied from interface:Rebufferer
Rebuffer (move on or seek to) a given position, and return a buffer that can be used there. The only guarantee about the size of the returned data is that unless rebuffering at the end of the file, the buffer will not be empty and will contain the requested position, i.e.offset <= position < offset + bh.buffer().limit()
, but the buffer will not be positioned there.- Specified by:
rebuffer
in interfaceRebufferer
- Overrides:
rebuffer
in classWrappingRebufferer
-
toString
public java.lang.String toString()
- Overrides:
toString
in classWrappingRebufferer
-
-